class TestUsers(unittest.TestCase): NUMBER_OF_USER_TESTS = 12 def setUp(self): self.users = Users(USER_LIST) def test_should_find_five_users(self): self.assertEqual(5, len(self.users.users)) def test_initially_test_counts_are_zero(self): for user in self.users.users: self.assertEqual(0, user.test_count) def test_all_admin_users_are_found(self): admins = set() for x in range(self.NUMBER_OF_USER_TESTS): user = self.users.find_user(Requirements(is_admin=True)) if user not in admins: admins.add(user) self.assertEqual(NUMBER_OF_ADMINS, len(admins)) admin_names = list(user.auth_user for user in admins) self.assertTrue("admin" in admin_names) self.assertTrue("anne" in admin_names) self.assertTrue("dan" in admin_names) expected_test_count = self.NUMBER_OF_USER_TESTS / NUMBER_OF_ADMINS for user in admins: self.assertTrue(user.requirements.is_admin) self.assertEqual(expected_test_count, user.test_count) def test_all_non_admin_users_are_found(self): normals = set() for x in range(self.NUMBER_OF_USER_TESTS): user = self.users.find_user(Requirements(is_admin=False)) if user not in normals: normals.add(user) self.assertEqual(NUMBER_OF_NORMALS, len(normals)) normal_names = list(user.auth_user for user in normals) self.assertTrue("mike" in normal_names) self.assertTrue("tim" in normal_names) expected_test_count = self.NUMBER_OF_USER_TESTS / NUMBER_OF_NORMALS for user in normals: self.assertFalse(user.requirements.is_admin) self.assertEqual(expected_test_count, user.test_count)