Best Python code snippet using tempest_python
test_models.py
Source:test_models.py
...30 self.assertEqual(self.group.total_admins, 1)31 def test_is_admin(self):32 self.assertTrue(self.group.is_admin(self.user))33 # Members34 def test_remove_member(self):35 ClubMember.objects.create(user=self.user, group=self.group)36 self.assertTrue(self.group.is_member(self.user))37 self.group.remove_member(self.user)38 self.assertFalse(self.group.is_member(self.user))39 def test_is_member(self):40 ClubMember.objects.create(user=self.user, group=self.group)41 self.assertTrue(self.group.is_member(self.user))42 def test_total_members(self):43 self.assertEqual(self.group.total_members, 0)44 def test_total_followers(self):45 # Should have one, because creators are set to auto-follow46 self.assertEqual(self.group.total_followers, 1)47class CustomGroupTests(TestCase):48 def setUp(self):49 self.uni = University.objects.create(name='foo')50 self.user = get_user_model().objects.create(uni=self.uni)51 self.group = CustomGroup.objects.create(user=self.user, uni=self.uni)52 # Admin (Customgroups don't have admins)53 def test_add_admin(self):54 with self.assertRaises(NotImplementedError):55 self.group.add_admin(self.user)56 def test_remove_admin(self):57 with self.assertRaises(NotImplementedError):58 self.group.remove_admin(self.user)59 def test_is_admin(self):60 self.assertFalse(self.group.is_admin(self.user))61 def test_total_admins(self):62 self.assertEqual(self.group.total_admins, 0)63 # Member64 def test_remove_member(self):65 CustomGroupMember.objects.create(user=self.user, group=self.group)66 self.assertTrue(self.group.is_member(self.user))67 self.group.remove_member(self.user)68 self.assertFalse(self.group.is_member(self.user))69 def test_is_member(self):70 CustomGroupMember.objects.create(user=self.user, group=self.group)71 self.assertTrue(self.group.is_member(self.user))72 def test_total_members(self):73 self.assertEqual(self.group.total_members, 0)74class StudentServiceTests(TestCase):75 def setUp(self):76 self.uni = University.objects.create(name='foo')77 self.user = get_user_model().objects.create(uni=self.uni)78 self.group = StudentService.objects.create(user=self.user, uni=self.uni)79 # Admins80 def test_add_admin(self):81 self.group.add_admin(self.user)82 self.assertTrue(self.group.is_admin(self.user))83 def test_add_admin_twice(self):84 self.group.add_admin(self.user)85 self.group.add_admin(self.user)86 self.assertEqual(self.group.total_admins, 1)87 def test_remove_admin(self):88 self.group.remove_admin(self.user)89 self.assertFalse(self.group.is_admin(self.user))90 def test_is_admin(self):91 StudentServiceAdmin.objects.create(user=self.user, group=self.group)92 self.assertTrue(self.group.is_admin(self.user))93 def test_total_admins(self):94 # Should have one, because the user who created the group should be95 # added as admin96 self.assertEqual(self.group.total_admins, 1)97 # Members98 def test_remove_member(self):99 StudentServiceMember.objects.create(user=self.user, group=self.group)100 self.assertTrue(self.group.is_member(self.user))101 self.group.remove_member(self.user)102 self.assertFalse(self.group.is_member(self.user))103 def test_is_member(self):104 StudentServiceMember.objects.create(user=self.user, group=self.group)105 self.assertTrue(self.group.is_member(self.user))106 def test_total_members(self):107 self.assertEqual(self.group.total_members, 0)108class StudyGroupTests(TestCase):109 def setUp(self):110 self.uni = University.objects.create(name='foo')111 self.user = get_user_model().objects.create(uni=self.uni)112 self.group = StudyGroup.objects.create(113 user=self.user, uni=self.uni, time_from='00:00:00',114 time_to='11:59:59', time_day=1)115 # Admin (Studygroups don't have admins)116 def test_add_admin(self):117 with self.assertRaises(NotImplementedError):118 self.group.add_admin(self.user)119 def test_remove_admin(self):120 with self.assertRaises(NotImplementedError):121 self.group.remove_admin(self.user)122 def test_is_admin(self):123 self.assertFalse(self.group.is_admin(self.user))124 def test_total_admins(self):125 self.assertEqual(self.group.total_admins, 0)126 # Member127 def test_remove_member(self):128 StudyGroupMember.objects.create(user=self.user, group=self.group)129 self.assertTrue(self.group.is_member(self.user))130 self.group.remove_member(self.user)131 self.assertFalse(self.group.is_member(self.user))132 def test_is_member(self):133 StudyGroupMember.objects.create(user=self.user, group=self.group)134 self.assertTrue(self.group.is_member(self.user))135 def test_total_members(self):136 self.assertEqual(self.group.total_members, 0)137class MentorGroupTests(TestCase):138 def setUp(self):139 self.uni = University.objects.create(name='foo')140 self.user = get_user_model().objects.create(uni=self.uni)141 self.group = MentorGroup.objects.create(user=self.user, uni=self.uni)142 # Admins (Mentor groups don't have admins)143 def test_add_admin(self):144 with self.assertRaises(NotImplementedError):145 self.group.add_admin(self.user)146 def test_remove_admin(self):147 with self.assertRaises(NotImplementedError):148 self.group.remove_admin(self.user)149 def test_is_admin(self):150 self.assertFalse(self.group.is_admin(self.user))151 def test_total_admins(self):152 self.assertEqual(self.group.total_admins, 0)153 # Members154 def test_remove_member(self):155 MentorGroupMember.objects.create(user=self.user, group=self.group)156 self.assertTrue(self.group.is_member(self.user))157 self.group.remove_member(self.user)158 self.assertFalse(self.group.is_member(self.user))159 def test_is_member(self):160 MentorGroupMember.objects.create(user=self.user, group=self.group)161 self.assertTrue(self.group.is_member(self.user))162 def test_total_members(self):163 self.assertEqual(self.group.total_members, 0)164class ClubMemberTests(TestCase):165 def setUp(self):166 self.uni = University.objects.create(name='foo')167 self.user = get_user_model().objects.create(168 uni=self.uni, name='foo')...
test_project_remove_member.py
Source:test_project_remove_member.py
1from core.browser.chrome import Chrome2from core.base.base_case import BaseCase3from core.base.parse import usr_2_name4class TestCaseRemoveMember(BaseCase):5 def test_remove_member(self):6 """移é¤ç¨æ·æµè¯"""7 Chrome.Project.open_project_menu()8 Chrome.Project.open_project_settings('æå管ç')...
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!!