Best Python code snippet using Kiwi_python
test_assign_permissions.py
Source:test_assign_permissions.py
2from django.contrib.auth.models import Group, Permission3from django.test import TestCase4from tcms.utils.permissions import assign_default_group_permissions5class TestAssignDefaultGroupPermissions(TestCase):6 """Test utils.permissions.assign_default_group_permissions()"""7 def setUp(self):8 self.admin = Group.objects.get(name="Administrator")9 self.admin.permissions.all().delete()10 self.tester = Group.objects.get(name="Tester")11 self.tester.permissions.all().delete()12 def test_administrator_has_all_permissions(self):13 assign_default_group_permissions()14 self.assertEqual(15 Permission.objects.all().count(), self.admin.permissions.count()16 )17 def test_tester_has_kiwi_apps_permissions(self):18 kiwi_apps = [19 "django_comments",20 "linkreference",21 "management",22 "testcases",23 "testplans",24 "testruns",25 ]26 if "tcms.bugs.apps.AppConfig" in settings.INSTALLED_APPS:27 kiwi_apps.append("bugs")28 assign_default_group_permissions()29 for app_name in kiwi_apps:30 self.assertTrue(31 self.tester.permissions.filter(32 pk__in=Permission.objects.filter(33 content_type__app_label__contains=app_name34 )35 ).exists()36 )37 self.assertEqual(38 Permission.objects.filter(39 content_type__app_label__contains=app_name40 ).count(),41 self.tester.permissions.filter(42 content_type__app_label__contains=app_name...
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!!