How to use test_empty_query method in Kiwi

Best Python code snippet using Kiwi_python

test_search_queries_nodes.py

Source:test_search_queries_nodes.py Github

copy

Full Screen

...53NODE_INDEX = {54 "index": ["test_nodes"]55}56class TestSearchNodesGlobal(AbstractPillarTest):57 def test_empty_query(self):58 with self.app.app_context():59 search = create_node_search(query='', terms={}, page=0)60 expected = {61 **EMPTY_QUERY,62 **AGGREGATIONS,63 **SORTED_DESC_BY_CREATED,64 **PAGE_165 }66 self.assertEqual(expected, search.to_dict())67 def test_empty_query_page_2(self):68 with self.app.app_context():69 search = create_node_search(query='', terms={}, page=1)70 page_2 = copy.deepcopy(PAGE_1)71 page_2['from'] = 1072 expected = {73 **EMPTY_QUERY,74 **AGGREGATIONS,75 **SORTED_DESC_BY_CREATED,76 **page_277 }78 self.assertEqual(expected, search.to_dict())79 def test_empty_query_with_terms(self):80 with self.app.app_context():81 terms = {82 'is_free': '0',83 'node_type': 'asset',84 }85 search = create_node_search(query='', terms=terms, page=0)86 query = copy.deepcopy(EMPTY_QUERY)87 query['query']['bool']['filter'] = [88 {89 "term": {90 "is_free": False91 }92 },93 {94 "term": {95 "node_type": "asset"96 }97 }98 ]99 expected = {100 **query,101 **AGGREGATIONS,102 **SORTED_DESC_BY_CREATED,103 **PAGE_1104 }105 self.assertEqual(expected, search.to_dict())106 def test_query(self):107 with self.app.app_context():108 search = create_node_search(query='is there life on mars?', terms={}, page=0)109 query = copy.deepcopy(EMPTY_QUERY)110 query['query']['bool']['must'] = [111 {112 "bool": {113 "should": [114 {115 "match": {116 "name": "is there life on mars?"117 }118 },119 {120 "match": {121 "project.name": "is there life on mars?"122 }123 },124 {125 "match": {126 "user.name": "is there life on mars?"127 }128 },129 {130 "match": {131 "description": "is there life on mars?"132 }133 },134 {135 "term": {136 "media": "is there life on mars?"137 }138 },139 {140 "term": {141 "tags": "is there life on mars?"142 }143 }144 ]145 }146 }147 ]148 expected = {149 **query,150 **AGGREGATIONS,151 **PAGE_1152 }153 self.assertEqual(expected, search.to_dict())154class TestSearchNodesInProject(AbstractPillarTest):155 def test_empty_query(self):156 with self.app.app_context():157 search = create_node_search(query='', terms={}, page=0, project_id='MyProjectId')158 project_query = copy.deepcopy(EMPTY_QUERY)159 project_query['query']['bool']['filter'] = [IN_PROJECT]160 expected = {161 **project_query,162 **AGGREGATIONS,163 **SORTED_DESC_BY_CREATED,164 **PAGE_1165 }166 self.assertEqual(expected, search.to_dict())167 def test_empty_query_page_2(self):168 with self.app.app_context():169 search = create_node_search(query='', terms={}, page=1, project_id='MyProjectId')...

Full Screen

Full Screen

test_search_queries_users.py

Source:test_search_queries_users.py Github

copy

Full Screen

...30 "from": 0,31 "size": 1032}33class TestSearchUsers(AbstractPillarTest):34 def test_empty_query(self):35 with self.app.app_context():36 search = queries.create_user_search(query='', terms={}, page=0)37 expected = {38 **SOURCE,39 **EMPTY_QUERY,40 **AGGREGATIONS,41 **PAGE_142 }43 self.assertEqual(expected, search.to_dict())44 def test_query(self):45 with self.app.app_context():46 search = queries.create_user_search(query='Jens', terms={}, page=0)47 query = copy.deepcopy(EMPTY_QUERY)48 query['query']['bool']['must'] = [49 {50 "bool": {51 "should": [52 {53 "match": {54 "username": "Jens"55 }56 },57 {58 "match": {59 "full_name": "Jens"60 }61 },62 {63 "match": {64 "email": {65 "query": "Jens",66 "boost": 167 }68 }69 },70 {71 "term": {72 "username_exact": {73 "value": "Jens",74 "boost": 5075 }76 }77 }78 ]79 }80 }81 ]82 expected = {83 **SOURCE,84 **query,85 **AGGREGATIONS,86 **PAGE_187 }88 self.assertEqual(expected, search.to_dict())89 def test_email_query(self):90 with self.app.app_context():91 search = queries.create_user_search(query='mail@mail.com', terms={}, page=0)92 query = copy.deepcopy(EMPTY_QUERY)93 query['query']['bool']['must'] = [94 {95 "bool": {96 "should": [97 {98 "term": {99 "email_exact": {100 "value": "mail@mail.com",101 "boost": 50102 }103 }104 },105 {106 "match": {107 "username": "mail@mail.com"108 }109 },110 {111 "match": {112 "full_name": "mail@mail.com"113 }114 },115 {116 "match": {117 "email": {118 "query": "mail@mail.com",119 "boost": 25120 }121 }122 },123 {124 "term": {125 "username_exact": {126 "value": "mail@mail.com",127 "boost": 50128 }129 }130 }131 ]132 }133 }134 ]135 expected = {136 **SOURCE,137 **query,138 **AGGREGATIONS,139 **PAGE_1140 }141 self.assertEqual(expected, search.to_dict())142class TestSearchUsersAdmin(AbstractPillarTest):143 def test_empty_query(self):144 with self.app.app_context():145 search = queries.create_user_admin_search(query='', terms={}, page=0)146 expected = {147 **EMPTY_QUERY,148 **AGGREGATIONS,149 **PAGE_1150 }151 self.assertEqual(expected, search.to_dict())152 def test_query(self):153 with self.app.app_context():154 search = queries.create_user_admin_search(query='Jens', terms={}, page=0)155 query = copy.deepcopy(EMPTY_QUERY)156 query['query']['bool']['must'] = [157 {...

Full Screen

Full Screen

test_views.py

Source:test_views.py Github

copy

Full Screen

...12class TestSearchView(TestCase):13 def setUp(self):14 self.url = reverse("jobs:search")15 super().setUp()16 def test_empty_query(self):17 jobs = Job.objects.filter(title__contains="software")18 response = self.client.get(self.url + "?position=software")19 self.assertFalse(b"We have found %a jobs" % str(jobs.count()) in response.content.lower())20class TestJobDetailsView(TestCase):21 def test_details(self):22 response = self.client.get(reverse("jobs:jobs-detail", args=(1,)))...

Full Screen

Full Screen

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 Kiwi 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