How to use assert_results method in Slash

Best Python code snippet using slash

base.py

Source:base.py Github

copy

Full Screen

...103 pins = [Pin(id=i, created_at=now + datetime.timedelta(hours=i))104 for i in ids_list]105 pins_ids = zip(pins, ids_list)106 return [FakeActivity(i, PinVerb, pin, i, now + datetime.timedelta(hours=i), {'i': i}) for pin, i in pins_ids]107 def assert_results(self, results, activities, msg=''):108 activity_ids = []109 extra_context = []110 for result in results:111 if hasattr(result, 'serialization_id'):112 activity_ids.append(result.serialization_id)113 else:114 activity_ids.append(result)115 if hasattr(result, 'extra_context'):116 extra_context.append(result.extra_context)117 compare_lists(118 activity_ids, [a.serialization_id for a in activities], msg)119 if extra_context:120 self.assertEquals(121 [a.extra_context for a in activities], extra_context)122 @implementation123 def test_count_empty(self):124 assert self.storage.count(self.test_key) == 0125 @implementation126 def test_count_insert(self):127 assert self.storage.count(self.test_key) == 0128 activity = self._build_activity_list([1])[0]129 self.storage.add(self.test_key, activity)130 assert self.storage.count(self.test_key) == 1131 @implementation132 def test_add_many(self):133 results = self.storage.get_slice(self.test_key, 0, None)134 # make sure no data polution135 assert results == []136 activities = self._build_activity_list(range(3, 0, -1))137 self.storage.add_many(self.test_key, activities)138 results = self.storage.get_slice(self.test_key, 0, None)139 self.assert_results(results, activities)140 @implementation141 def test_add_many_unique(self):142 activities = self._build_activity_list(143 list(range(3, 0, -1)) + list(range(3, 0, -1)))144 self.storage.add_many(self.test_key, activities)145 results = self.storage.get_slice(self.test_key, 0, None)146 self.assert_results(results, activities[:3])147 @implementation148 def test_contains(self):149 activities = self._build_activity_list(range(4, 0, -1))150 self.storage.add_many(self.test_key, activities[:3])151 results = self.storage.get_slice(self.test_key, 0, None)152 if self.storage.contains:153 self.assert_results(results, activities[:3])154 for a in activities[:3]:155 assert self.storage.contains(self.test_key, a.serialization_id)156 assert not self.storage.contains(157 self.test_key, activities[3].serialization_id)158 @implementation159 def test_index_of(self):160 activities = self._build_activity_list(range(1, 43))161 activity_ids = [a.serialization_id for a in activities]162 self.storage.add_many(self.test_key, activities)163 assert self.storage.index_of(self.test_key, activity_ids[41]) == 0164 assert self.storage.index_of(self.test_key, activity_ids[7]) == 34165 with self.assertRaises(ValueError):166 self.storage.index_of(self.test_key, 0)167 @implementation168 def test_trim(self):169 activities = self._build_activity_list(range(10, 0, -1))170 for a in activities[5:] + activities[:5]:171 time.sleep(0.1)172 self.storage.add_many(self.test_key, [a])173 assert self.storage.count(self.test_key) == 10174 self.storage.trim(self.test_key, 5)175 assert self.storage.count(self.test_key) == 5176 results = self.storage.get_slice(self.test_key, 0, None)177 self.assert_results(178 results, activities[:5], 'check trim direction')179 @implementation180 def test_noop_trim(self):181 activities = self._build_activity_list(range(10, 0, -1))182 self.storage.add_many(self.test_key, activities)183 assert self.storage.count(self.test_key) == 10184 self.storage.trim(self.test_key, 12)185 assert self.storage.count(self.test_key) == 10186 @implementation187 def test_trim_empty_feed(self):188 self.storage.trim(self.test_key, 12)189 @implementation190 def test_remove_missing(self):191 activities = self._build_activity_list(range(10))192 self.storage.remove(self.test_key, activities[1])193 self.storage.remove_many(self.test_key, activities[1:2])194 @implementation195 def test_add_remove(self):196 assert self.storage.count(self.test_key) == 0197 activities = self._build_activity_list(range(10, 0, -1))198 self.storage.add_many(self.test_key, activities)199 self.storage.remove_many(self.test_key, activities[5:])200 results = self.storage.get_slice(self.test_key, 0, 20)201 assert self.storage.count(self.test_key) == 5202 self.assert_results(results, activities[:5])203 @implementation204 def test_get_many_empty(self):205 assert self.storage.get_slice(self.test_key, 0, 10) == []206 @implementation207 def test_timeline_order(self):208 activities = self._build_activity_list(range(10, 0, -1))209 self.storage.add_many(self.test_key, activities)210 self.storage.trim(self.test_key, 5)211 self.storage.add_many(self.test_key, activities)212 results = self.storage.get_slice(self.test_key, 0, 5)213 self.assert_results(results, activities[:5])214 @implementation215 def test_implements_batcher_as_ctx_manager(self):216 batcher = self.storage.get_batch_interface()217 hasattr(batcher, '__enter__')218 hasattr(batcher, '__exit__')219 @implementation220 def test_union_set_slice(self):221 activities = self._build_activity_list(range(42, 0, -1))222 self.storage.add_many(self.test_key, activities)223 assert self.storage.count(self.test_key) == 42224 s1 = self.storage.get_slice(self.test_key, 0, 21)225 self.assert_results(s1, activities[0:21])226 s2 = self.storage.get_slice(self.test_key, 22, 42)227 self.assert_results(s2, activities[22:42])228 s3 = self.storage.get_slice(self.test_key, 22, 23)229 self.assert_results(s3, activities[22:23])230 s4 = self.storage.get_slice(self.test_key, None, 23)231 self.assert_results(s4, activities[:23])232 s5 = self.storage.get_slice(self.test_key, None, None)233 self.assert_results(s5, activities[:])234 s6 = self.storage.get_slice(self.test_key, 1, None)235 self.assert_results(s6, activities[1:])236 # check intersections...

Full Screen

Full Screen

test_containers.py

Source:test_containers.py Github

copy

Full Screen

...79 loc_move = self.Operation.Move.create(input=loc_av,80 destination=other,81 state='planned',82 dt_execution=self.dt_test2)83 def assert_results(expected, **kwargs):84 cte = PhysObj.flatten_containers_subquery(**kwargs)85 self.assertEqual(86 set(PhysObj.query().join(cte, cte.c.id == PhysObj.id).all()),87 expected)88 # starting point, just to check89 assert_results({stock, loc}, top=stock)90 assert_results({other}, top=other)91 for dt in (self.dt_test2, self.dt_test3, DATE_TIME_INFINITY):92 assert_results({stock},93 top=stock,94 additional_states=['future'],95 at_datetime=dt)96 assert_results({other, loc},97 top=other,98 additional_states=['future'],99 at_datetime=dt)100 loc_move.execute(dt_execution=self.dt_test2)101 assert_results({stock}, top=stock)102 assert_results({other, loc}, top=other)103 assert_results({stock, loc},104 top=stock,105 additional_states=['past'],106 at_datetime=self.dt_test1)107 assert_results({other},108 top=other,109 additional_states=['past'],...

Full Screen

Full Screen

test_form_search.py

Source:test_form_search.py Github

copy

Full Screen

...39 'country_id': country_id,40 }).id)41 cls.expected_partners = \42 cls.partner_model.browse(cls.expected_partners_ids)43 def assert_results(self, form, count, expected):44 self.assertTrue('results' in form.form_search_results)45 self.assertTrue('count' in form.form_search_results)46 self.assertTrue('pager' in form.form_search_results)47 self.assertEqual(len(form.form_search_results['results']), count)48 self.assertEqual(form.form_search_results['count'], count)49 self.assertEqual(50 sorted(form.form_search_results['results'].mapped('id')),51 sorted(expected.mapped('id')),52 )53 def get_search_form(54 self, data, form_model='cms.form.search.res.partner', **kw):55 request = fake_request(form_data=data)56 form = self.get_form(form_model, req=request, **kw)57 # restrict search results to these ids58 form.test_record_ids = self.expected_partners_ids59 return form60 def test_search(self):61 data = {'name': 'Salmo', }62 form = self.get_search_form(data)63 form.form_process()64 self.assert_results(form, 1, self.expected_partners[:1])65 data = {'name': 'Marracash', }66 form = self.get_search_form(data)67 form.form_process()68 self.assert_results(form, 1, self.expected_partners[1:2])69 data = {'country_id': self.env.ref('base.it').id, }70 form = self.get_search_form(data)71 form.form_process()72 self.assert_results(form, 2, self.expected_partners[:2])73 data = {'country_id': self.env.ref('base.fr').id, }74 form = self.get_search_form(data)75 form.form_process()76 self.assert_results(form, 1, self.expected_partners[4:])77 data = {'name': '', 'country_id': self.env.ref('base.fr').id, }78 form = self.get_search_form(data)79 form.form_process()80 self.assert_results(form, 1, self.expected_partners[4:])81 def test_search_multi(self):82 countries = [83 self.env.ref('base.it').id,84 self.env.ref('base.fr').id,85 ]86 data = {'country_id': ','.join(map(str, countries))}87 form = self.get_search_form(88 data, form_model='cms.form.search.res.partner.multicountry')89 form.form_process()90 expected = self.expected_partners.filtered(91 lambda x: x.country_id.id in countries)92 self.assert_results(form, 3, expected)93 def test_search_form_bypass_security_check(self):94 form = self.get_search_form(95 {}, sudo_uid=self.env.ref('base.public_user').id)96 self.assertTrue(form.form_check_permission())97 def test_search_custom_rules(self):98 data = {'country_id': 'Italy', }99 form = self.get_search_form(data)100 form.form_process()101 # we find them all since domain is mocked to include all test partners102 self.assert_results(form, 5, self.expected_partners)103 # apply custom rules104 data = {'country_id': 'Italy', }105 form = self.get_search_form(data, search_domain_rules={106 'country_id': ('country_id.name', 'ilike', '')107 })108 form.form_process()...

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