Best Python code snippet using lisa_python
test_views.py
Source:test_views.py
...52 def test_cache_purge_view_no_permission(self):53 self._create_test_cache()54 self._create_test_cache_partition()55 self._create_test_cache_partition_file()56 cache_total_size = self.test_cache.get_total_size()57 self._clear_events()58 response = self._request_test_cache_purge_view()59 self.assertEqual(response.status_code, 404)60 self.assertEqual(cache_total_size, self.test_cache.get_total_size())61 events = self._get_test_events()62 self.assertEqual(events.count(), 0)63 def test_cache_purge_view_with_access(self):64 self._create_test_cache()65 self._create_test_cache_partition()66 self._create_test_cache_partition_file()67 self.grant_access(68 obj=self.test_cache, permission=permission_cache_purge69 )70 cache_total_size = self.test_cache.get_total_size()71 self._clear_events()72 response = self._request_test_cache_purge_view()73 self.assertEqual(response.status_code, 302)74 self.assertNotEqual(cache_total_size, self.test_cache.get_total_size())75 events = self._get_test_events()76 self.assertEqual(events.count(), 2)77 self.assertEqual(events[0].action_object, None)78 self.assertEqual(events[0].actor, self._test_case_user)79 self.assertEqual(events[0].target, self.test_cache_partition)80 self.assertEqual(events[0].verb, event_cache_partition_purged.id)81 self.assertEqual(events[1].action_object, None)82 self.assertEqual(events[1].actor, self._test_case_user)83 self.assertEqual(events[1].target, self.test_cache)84 self.assertEqual(events[1].verb, event_cache_purged.id)85 def test_cache_multiple_purge_view_no_permission(self):86 self._create_test_cache()87 self._create_test_cache_partition()88 self._create_test_cache_partition_file()89 cache_total_size = self.test_cache.get_total_size()90 self._clear_events()91 response = self._request_test_cache_multiple_purge_view()92 self.assertEqual(response.status_code, 404)93 self.assertEqual(cache_total_size, self.test_cache.get_total_size())94 events = self._get_test_events()95 self.assertEqual(events.count(), 0)96 def test_cache_multiple_purge_view_with_access(self):97 self._create_test_cache()98 self._create_test_cache_partition()99 self._create_test_cache_partition_file()100 self.grant_access(101 obj=self.test_cache, permission=permission_cache_purge102 )103 cache_total_size = self.test_cache.get_total_size()104 self._clear_events()105 response = self._request_test_cache_multiple_purge_view()106 self.assertEqual(response.status_code, 302)107 self.assertNotEqual(cache_total_size, self.test_cache.get_total_size())108 events = self._get_test_events()109 self.assertEqual(events.count(), 2)110 self.assertEqual(events[0].action_object, None)111 self.assertEqual(events[0].actor, self._test_case_user)112 self.assertEqual(events[0].target, self.test_cache_partition)113 self.assertEqual(events[0].verb, event_cache_partition_purged.id)114 self.assertEqual(events[1].action_object, None)115 self.assertEqual(events[1].actor, self._test_case_user)116 self.assertEqual(events[1].target, self.test_cache)...
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!!