How to use test_nest method in hypothesis

Best Python code snippet using hypothesis

test_nested_where_filters.py

Source: test_nested_where_filters.py Github

copy

Full Screen

1import pytest2from datagateway_api.src.search_api.filters import SearchAPIWhereFilter3from datagateway_api.src.search_api.nested_where_filters import NestedWhereFilters4from datagateway_api.src.search_api.query import SearchAPIQuery5class TestNestedWhereFilters:6 @pytest.mark.parametrize(7 "lhs, rhs, joining_operator, expected_where_clause",8 [9 pytest.param("A", None, "AND", "(A)", id="LHS (A) w/​ misc. AND"),10 pytest.param("A", None, "OR", "(A)", id="LHS (A) w/​ misc. OR"),11 pytest.param([], "A", "AND", "(A)", id="RHS (A) w/​ misc. AND"),12 pytest.param([], "A", "OR", "(A)", id="RHS (A) w/​ misc. OR"),13 pytest.param("A", "B", "AND", "(A AND B)", id="(A AND B)"),14 pytest.param("A", "B", "OR", "(A OR B)", id="(A OR B)"),15 pytest.param(16 "(A AND B)",17 "(C AND D)",18 "AND",19 "((A AND B) AND (C AND D))",20 id="((A AND B) AND (C AND D))",21 ),22 pytest.param(23 "(A AND B)",24 "(C AND D)",25 "OR",26 "((A AND B) OR (C AND D))",27 id="((A AND B) OR (C AND D))",28 ),29 pytest.param(30 "(A OR B)",31 "(C OR D)",32 "OR",33 "((A OR B) OR (C OR D))",34 id="((A OR B) OR (C OR D))",35 ),36 pytest.param(37 "(A OR B)",38 "(C OR D)",39 "AND",40 "((A OR B) AND (C OR D))",41 id="((A OR B) AND (C OR D))",42 ),43 pytest.param(44 "(A AND B AND C) OR (C AND D)",45 "(E AND F)",46 "OR",47 "((A AND B AND C) OR (C AND D) OR (E AND F))",48 id="((A AND B AND C) OR (C AND D) OR (E AND F))",49 ),50 pytest.param(51 "(A AND B AND C) AND (C OR D)",52 "(E AND F)",53 "OR",54 "((A AND B AND C) AND (C OR D) OR (E AND F))",55 id="((A AND B AND C) AND (C OR D)) OR (E AND F))",56 ),57 pytest.param(58 "((A AND B AND C) AND (C OR D))",59 "(E AND F)",60 "OR",61 "(((A AND B AND C) AND (C OR D)) OR (E AND F))",62 id="(((A AND B AND C) AND (C OR D))) OR (E AND F))",63 ),64 ],65 )66 def test_str_filters(self, lhs, rhs, joining_operator, expected_where_clause):67 test_nest = NestedWhereFilters(lhs, rhs, joining_operator)68 where_clause = str(test_nest)69 assert where_clause == expected_where_clause70 @pytest.mark.parametrize(71 "lhs, rhs, joining_operator, query, expected_where_clause",72 [73 pytest.param(74 SearchAPIWhereFilter("name", "test name", "eq"),75 SearchAPIWhereFilter("id", 3, "eq"),76 "OR",77 SearchAPIQuery("File"),78 "(o.name = 'test name' OR o.id = '3')",79 id="(o.title = 'test name' OR o.id = '3')",80 ),81 pytest.param(82 [SearchAPIWhereFilter("name", "test name", "eq")],83 SearchAPIWhereFilter("id", 3, "eq"),84 "OR",85 SearchAPIQuery("File"),86 "(o.name = 'test name' OR o.id = '3')",87 id="Single filter list in LHS",88 ),89 pytest.param(90 [SearchAPIWhereFilter("name", "test name", "eq")],91 [SearchAPIWhereFilter("id", 3, "eq")],92 "OR",93 SearchAPIQuery("File"),94 "(o.name = 'test name' OR o.id = '3')",95 id="Single filter list in LHS and RHS",96 ),97 pytest.param(98 [99 SearchAPIWhereFilter("name", "test name", "eq"),100 SearchAPIWhereFilter("id", 10, "lt"),101 ],102 [SearchAPIWhereFilter("id", 3, "gt")],103 "AND",104 SearchAPIQuery("File"),105 "(o.name = 'test name' AND o.id < '10' AND o.id > '3')",106 id="Multiple filters on LHS",107 ),108 pytest.param(109 [110 SearchAPIWhereFilter("title", "test name", "eq"),111 SearchAPIWhereFilter("pid", "test doi", "like"),112 ],113 [114 SearchAPIWhereFilter("doi", "doi test", "neq"),115 SearchAPIWhereFilter("summary", "Test Summary", "like"),116 ],117 "AND",118 SearchAPIQuery("Document"),119 "(o.name = 'test name' AND o.doi like '%test doi%' AND o.doi != "120 "'doi test' AND o.summary like '%Test Summary%')",121 id="Multiple filters on LHS and RHS",122 ),123 ],124 )125 def test_search_api_filters(126 self, lhs, rhs, joining_operator, query, expected_where_clause,127 ):128 test_nest = NestedWhereFilters(lhs, rhs, joining_operator, query)129 where_clause = str(test_nest)130 assert where_clause == expected_where_clause131 @pytest.mark.parametrize(132 "lhs, rhs, joining_operator, expected_where_clause",133 [134 pytest.param(135 NestedWhereFilters("A", "B", "OR"),136 NestedWhereFilters("C", "D", "AND"),137 "OR",138 "((A OR B) OR (C AND D))",139 id="((A OR B) OR (C AND D))",140 ),141 ],142 )143 def test_nested_classes(144 self, lhs, rhs, joining_operator, expected_where_clause,145 ):146 test_nest = NestedWhereFilters(lhs, rhs, joining_operator)147 where_clause = str(test_nest)148 assert where_clause == expected_where_clause149 @pytest.mark.parametrize(150 "test_filters, query",151 [152 pytest.param(153 SearchAPIWhereFilter("name", "test name", "eq"),154 SearchAPIQuery("File"),155 id="Single WHERE filter",156 ),157 pytest.param(158 NestedWhereFilters(159 [SearchAPIWhereFilter("name", "test name", "eq")],160 [SearchAPIWhereFilter("id", 3, "eq")],161 "OR",162 SearchAPIQuery("File"),163 ),164 SearchAPIQuery("File"),165 id="NestedWhereFilters object",166 ),167 pytest.param(168 [169 SearchAPIWhereFilter("name", "test name", "eq"),170 SearchAPIWhereFilter("id", 3, "eq"),171 ],172 SearchAPIQuery("File"),173 id="List of WHERE filters",174 ),175 ],176 )177 def test_apply_filter(self, test_filters, query):178 NestedWhereFilters.set_search_api_query(test_filters, query)179 if not isinstance(test_filters, list):180 test_filters = [test_filters]181 for filter_ in test_filters:182 if isinstance(filter_, NestedWhereFilters):183 assert filter_.lhs[0].search_api_query == query184 assert filter_.rhs[0].search_api_query == query185 else:...

Full Screen

Full Screen

test_randomization.py

Source: test_randomization.py Github

copy

Full Screen

...30 @given(st.integers())31 @settings(32 max_examples=100, phases=no_shrink, database=None, verbosity=Verbosity.quiet33 )34 def test_nest(y):35 assert y < x36 with raises(AssertionError):37 test_nest()...

Full Screen

Full Screen

test_nesting.py

Source: test_nesting.py Github

copy

Full Screen

...22 @given(st.integers())23 @settings(24 max_examples=100, phases=no_shrink, database=None, verbosity=Verbosity.quiet25 )26 def test_nest(y):27 if y >= x:28 raise ValueError()29 with raises(ValueError):30 test_nest()...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

A Step-By-Step Guide To Cypress API Testing

API (Application Programming Interface) is a set of definitions and protocols for building and integrating applications. It’s occasionally referred to as a contract between an information provider and an information user establishing the content required from the consumer and the content needed by the producer.

What is coaching leadership

Coaching is a term that is now being mentioned a lot more in the leadership space. Having grown successful teams I thought that I was well acquainted with this subject.

Different Ways To Style CSS Box Shadow Effects

Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.

Getting Rid of Technical Debt in Agile Projects

Technical debt was originally defined as code restructuring, but in today’s fast-paced software delivery environment, it has evolved. Technical debt may be anything that the software development team puts off for later, such as ineffective code, unfixed defects, lacking unit tests, excessive manual tests, or missing automated tests. And, like financial debt, it is challenging to pay back.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful