Best Python code snippet using django-test-plus_python
mixins.py
Source:mixins.py
...72 self.assertEqual(response.status_code, 200, "Invalid status code on '{}'".format(url))73 def test_changelist_queries_limit(self):74 self.factory_cls.create_batch(size=20)75 url = reverse(self.get_changelist_viewname())76 with self.assertNumQueriesLessThan(self.QUERY_LIMIT):77 self.client.get(url)78 def test_change_view_queries_limit(self):79 self.factory_cls.create_batch(size=20)80 url = reverse(self.get_change_viewname(), args=[self.object.pk])81 with self.assertNumQueriesLessThan(self.QUERY_LIMIT):...
tests_view_standings.py
Source:tests_view_standings.py
...7 def test_anon_user(self):8 client = Client()9 response = client.get(reverse(views.standings))10 self.assertEqual(response.status_code, 302)11 @NmkUnitTestCase.assertNumQueriesLessThan(15)12 def test_regular_user(self):13 """14 Test visiting standings page15 """16 response = self.client.get(reverse(views.standings))17 self.assertEqual(response.status_code, 200)18 context = response.context19 self.check_full_standings_context(context)20 def check_full_standings_context(self, context):21 self.assertEqual(len(context['rounds']), 3)22 self.assertTrue(context['rounds'][0].id, 1)23 self.assertTrue(context['rounds'][1].id, 2)24 self.assertTrue(context['rounds'][2].id, 3)25 self.assertEqual(len(context['groups']), 2)26 self.assertTrue(1 in [g.id for g in context['groups']])27 self.assertTrue(2 in [g.id for g in context['groups']])28 self.assertEqual(context['selected_group'], '')29 self.assertEqual(len(context['standings']), 3)30 standings = context['standings']31 self.assertEqual(standings[0][0].user.id, 1)32 self.assertEqual(standings[0][0].user.email, 'kokan@mail.com')33 self.assertEqual(standings[0][1], [1.5, 9.0, 0.0])34 self.assertEqual(standings[1][0].user.id, 3)35 self.assertEqual(standings[1][0].user.email, 'seki@mail.com')36 self.assertEqual(standings[1][1], [0.0, 0.0, 0.0])37 self.assertEqual(standings[2][0].user.id, 2)38 self.assertEqual(standings[2][0].user.email, 'gumi@mail.com')39 self.assertEqual(standings[2][1], [0.0, 0.0, 0.0])40 @NmkUnitTestCase.assertNumQueriesLessThan(15)41 def test_other_group(self):42 link_with_group = '{}?group=kokangumi'.format(reverse(views.standings))43 response = self.client.get(link_with_group)44 self.assertEqual(response.status_code, 200)45 context = response.context46 self.assertEqual(len(context['rounds']), 3)47 self.assertTrue(context['rounds'][0].id, 1)48 self.assertTrue(context['rounds'][1].id, 2)49 self.assertTrue(context['rounds'][2].id, 3)50 self.assertEqual(len(context['groups']), 2)51 self.assertTrue(1 in [g.id for g in context['groups']])52 self.assertTrue(2 in [g.id for g in context['groups']])53 self.assertEqual(context['selected_group'], 'kokangumi')54 self.assertEqual(len(context['standings']), 2)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!