class GetContactInfo(unittest.TestCase): def setUp(self): self.ADMIN = Administrator("*****@*****.**", "adminPass") self.ADMIN.change_name("Dave Brubeck") self.ADMIN.change_phone(4141234567) self.SUPER = Supervisor("*****@*****.**", "superPass") self.SUPER.change_name("Donna Summer") self.SUPER.change_phone(4149876543) self.INSTR = Instructor("*****@*****.**", "instrPass") self.INSTR.change_name("Dean Martin") self.INSTR.change_phone(2621234567) self.T_AYY = TA("*****@*****.**", "t_ayyPass") self.T_AYY.change_name("Daniel Craig") self.T_AYY.change_phone(2629876543) def test_get_info_admin(self): self.ui.command("Login [email protected] adminPass") self.assertEqual( self.ui.command("get_contact_info"), "NAME PHONE EMAIL" "Dave Brubeck 414.123.4567 [email protected]" "Donna Summer 414.987.6543 [email protected]" "Dean Martin 262.123.4567 [email protected]" "Daniel Craig 262.987.6543 [email protected]") def test_get_info_super(self): self.ui.command("Login [email protected] adminPass") self.assertEqual( self.ui.command("get_contact_info"), "NAME PHONE EMAIL" "Dave Brubeck 414.123.4567 [email protected]" "Donna Summer 414.987.6543 [email protected]" "Dean Martin 262.123.4567 [email protected]" "Daniel Craig 262.987.6543 [email protected]") def test_get_info_inst(self): self.ui.command("Login [email protected] instrPass") self.assertEqual( self.ui.command("get_contact_info"), "NAME PHONE EMAIL" "Dave Brubeck 414.123.4567 [email protected]" "Donna Summer 414.987.6543 [email protected]" "Dean Martin 262.123.4567 [email protected]" "Daniel Craig 262.987.6543 [email protected]") def test_get_info_ta(self): self.ui.command("Login [email protected] t_ayyPass") self.assertEqual( self.ui.command("get_contact_info"), "NAME PHONE EMAIL" "Dave Brubeck 414.123.4567 [email protected]" "Donna Summer 414.987.6543 [email protected]" "Dean Martin 262.123.4567 [email protected]" "Daniel Craig 262.987.6543 [email protected]")
class AccessInfoTests(unittest.TestCase): def setUp(self): self.ADMIN = Administrator("*****@*****.**", "adminPass") self.ADMIN.change_name("Dave Brubeck") self.ADMIN.change_phone(4141234567) self.SUPER = Supervisor("*****@*****.**", "superPass") self.SUPER.change_name("Donna Summer") self.SUPER.change_phone(4149876543) self.INSTR = Instructor("*****@*****.**", "instrPass") self.INSTR.change_name("Dean Martin") self.INSTR.change_phone(2621234567) self.T_AYY = TA("*****@*****.**", "t_ayyPass") self.T_AYY.change_name("Daniel Craig") self.T_AYY.change_phone(2629876543) def test_valid_access_admin(self): self.ui.command("Login [email protected] adminPass") self.assertEqual( self.ui.command("AccessInfo"), "NAME PHONE EMAIL PASSWORD" "Dave Brubeck 414.123.4567 [email protected] adminPass" "Donna Summer 414.987.6543 [email protected] superPass" "Dean Martin 262.123.4567 [email protected] instrPass" "Daniel Craig 262.987.6543 [email protected] t_ayyPass") def test_valid_access_super(self): self.ui.command("Login [email protected] superPass") self.assertEqual( self.ui.command("AccessInfo"), "NAME PHONE EMAIL PASSWORD" "Dave Brubeck 414.123.4567 [email protected] adminPass" "Donna Summer 414.987.6543 [email protected] superPass" "Dean Martin 262.123.4567 [email protected] instrPass" "Daniel Craig 262.987.6543 [email protected] t_ayyPass") def test_invalid_access_instr(self): self.ui.command("Login [email protected] instrPass") self.assertEqual(self.ui.command("AccessInfo"), "Access Denied") def test_invalid_access_ta(self): self.ui.command("Login [email protected] t_ayyPass") self.assertEqual(self.ui.command("AccessInfo"), "Access Denied")
class TestTA(TestCase): def setUp(self): self.ta0 = TA("*****@*****.**", "password", "ta") self.ta1 = TA("*****@*****.**", "password", "ta") self.ta2 = TA("*****@*****.**", "password", "ta") self.ta3 = TA("*****@*****.**", "password", "ta") self.course1 = Course("CS101", 0) self.course2 = Course("CS201", 0) self.course3 = Course("CS301", 0) def test_view_ta_assignments1(self): mod_course1 = models.ModelCourse.objects.get(course_id="CS101") mod_ta_course1 = models.ModelTACourse() mod_ta_course1.course = mod_course1 mod_ta1 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course1.TA = mod_ta1 mod_ta_course1.save() self.assertEqual(self.ta1.view_ta_assignments()[0], "Course: CS101 TA: DEFAULT, [email protected]") def test_view_ta_assignments2(self): mod_course2 = models.ModelCourse.objects.get(course_id="CS201") mod_ta_course2 = models.ModelTACourse() mod_ta_course2.course = mod_course2 mod_ta2 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course2.TA = mod_ta2 mod_ta_course2.save() self.assertEqual(self.ta2.view_ta_assignments()[0], "Course: CS201 TA: DEFAULT, [email protected]") def test_view_ta_assignments3(self): mod_course3 = models.ModelCourse.objects.get(course_id="CS301") mod_ta_course3 = models.ModelTACourse() mod_ta_course3.course = mod_course3 mod_ta3 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course3.TA = mod_ta3 mod_ta_course3.save() self.assertEqual(self.ta3.view_ta_assignments()[0], "Course: CS301 TA: DEFAULT, [email protected]") def test_view_ta_assignments4(self): mod_course1 = models.ModelCourse.objects.get(course_id="CS101") mod_ta_course1 = models.ModelTACourse() mod_ta_course1.course = mod_course1 mod_ta1 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course1.TA = mod_ta1 mod_ta_course1.save() mod_course2 = models.ModelCourse.objects.get(course_id="CS201") mod_ta_course2 = models.ModelTACourse() mod_ta_course2.course = mod_course2 mod_ta2 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course2.TA = mod_ta2 mod_ta_course2.save() mod_course3 = models.ModelCourse.objects.get(course_id="CS301") mod_ta_course3 = models.ModelTACourse() mod_ta_course3.course = mod_course3 mod_ta3 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course3.TA = mod_ta3 mod_ta_course3.save() self.assertEqual(self.ta0.view_ta_assignments()[0], "Course: CS101 TA: DEFAULT, [email protected]") self.assertEqual(self.ta0.view_ta_assignments()[1], "Course: CS201 TA: DEFAULT, [email protected]") self.assertEqual(self.ta0.view_ta_assignments()[2], "Course: CS301 TA: DEFAULT, [email protected]") self.assertEqual(self.ta0.view_ta_assignments(), [ 'Course: CS101 TA: DEFAULT, [email protected]', 'Course: CS201 TA: DEFAULT, [email protected]', 'Course: CS301 TA: DEFAULT, [email protected]' ]) def test_read_public_contact(self): # self.assertEqual(self.ta1.read_public_contact(self.class_list)) pass def test_change_password(self): self.TA1 = TA("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.assertTrue(self.TA1.change_password("password")) self.assertEquals(self.TA1.password, "password") self.assertNotEquals(self.TA1.password, "DEFAULT_PASSWORD") model_person1 = models.ModelPerson.objects.get(email=self.TA1.email) self.assertEquals(model_person1.password, "password") def test_change_email(self): self.TA1 = TA("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.person2 = Person("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.TA1.change_email("*****@*****.**") model_person1 = models.ModelPerson.objects.get(email=self.TA1.email) self.assertEquals(model_person1.email, "*****@*****.**") self.assertEquals(self.TA1.email, "*****@*****.**") self.assertNotEquals(self.TA1.email, "*****@*****.**") self.assertFalse(self.TA1.change_email("*****@*****.**")) self.assertFalse( self.TA1.change_email("no_at_symbol_or_dot_something")) self.assertFalse(self.TA1.change_email("*****@*****.**")) def test_change_phone(self): self.TA1 = TA("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.TA1.change_phone("414.414.4141") model_person1 = models.ModelPerson.objects.get(email=self.TA1.email) self.assertEquals(model_person1.phone, "414.414.4141") self.assertEquals(self.TA1.phone_number, "414.414.4141") self.assertNotEquals(self.TA1.phone_number, "000.000.0000") self.assertFalse(self.TA1.change_phone("1234567890")) self.assertFalse(self.TA1.change_phone("414-414-4141")) self.assertFalse(self.TA1.change_phone("(414)414-4141")) self.assertFalse(self.TA1.change_phone("abc.abc.abcd")) self.assertFalse(self.TA1.change_phone("1234.1234.1234")) def test_change_name(self): self.TA1 = TA("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.TA1.change_name("Snoop Doggy Dog") model_person1 = models.ModelPerson.objects.get(email=self.TA1.email) self.assertEquals(model_person1.name, "Snoop Doggy Dog") self.assertEquals(self.TA1.name, "Snoop Doggy Dog") self.assertNotEquals(self.TA1.name, "DEFAULT")