def test_access_info_all_the_things(self): # ALL THE THINGS self.inst1 = Instructor("*****@*****.**", "password", "instructor") self.inst2 = Instructor("*****@*****.**", "password", "instructor") self.ta1 = TA("*****@*****.**", "password", "ta") self.ta2 = TA("*****@*****.**", "password", "ta") self.course1 = Course("CS101", 0) self.course2 = Course("CS102", 0) self.course1.instructor = "*****@*****.**" mod_course1 = models.ModelCourse.objects.get(course_id="CS101") mod_course1.instructor = "*****@*****.**" mod_course1.save() self.course2.instructor = "*****@*****.**" mod_course2 = models.ModelCourse.objects.get(course_id="CS102") mod_course2.instructor = "*****@*****.**" mod_course2.save() 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_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() access_info = self.ad1.access_info() parse_info = access_info.split("\n") self.assertEqual(parse_info[0], "Administrator:") self.assertEqual(parse_info[1], "DEFAULT | [email protected] | 000.000.0000") self.assertEqual(parse_info[2], "") self.assertEqual(parse_info[3], "Supervisor:") self.assertEqual(parse_info[4], "DEFAULT | [email protected] | 000.000.0000") self.assertEqual(parse_info[5], "") self.assertEqual(parse_info[6], "Instructors:") self.assertEqual(parse_info[7], "DEFAULT | [email protected] | 000.000.0000") self.assertEqual(parse_info[8], "\tCourse: CS101") self.assertEqual(parse_info[9], "") self.assertEqual(parse_info[10], "DEFAULT | [email protected] | 000.000.0000") self.assertEqual(parse_info[11], "\tCourse: CS102") self.assertEqual(parse_info[12], "") self.assertEqual(parse_info[13], "") self.assertEqual(parse_info[14], "TAs:") self.assertEqual(parse_info[15], "DEFAULT | [email protected] | 000.000.0000") self.assertEqual(parse_info[16], "\tCourse: CS101") self.assertEqual(parse_info[17], "") self.assertEqual(parse_info[18], "DEFAULT | [email protected] | 000.000.0000") self.assertEqual(parse_info[19], "\tCourse: CS102") self.assertEqual(parse_info[20], "") self.assertEqual(parse_info[21], "") self.assertEqual(parse_info[22], "Courses:") self.assertEqual(parse_info[23], "CS101") self.assertEqual(parse_info[24], "CS102")
def test_change_password(self): self.Instructor1 = Instructor("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.assertTrue(self.Instructor1.change_password("password")) self.assertEquals(self.Instructor1.password, "password") self.assertNotEquals(self.Instructor1.password, "DEFAULT_PASSWORD") model_person1 = models.ModelPerson.objects.get( email=self.Instructor1.email) self.assertEquals(model_person1.password, "password")
def setup(self): self.instructor1 = Instructor("*****@*****.**", "DEFAULT_PASSWORD") self.instructor2 = Instructor("*****@*****.**", "DEFAULT_PASSWORD") # fake TA self.ta1 = ("*****@*****.**", "DEFAULT_PASSWORD") self.ta2 = ("*****@*****.**", "DEFAULT_PASSWORD") # fake Course self.course1 = ("Course 1", 2, self.instructor1, [self.ta1]) self.course2 = ("Course 2", 2, self.instructor2, [self.ta2])
def setup(self): self.Sup = Supervisor("*****@*****.**", "SupervisorPassword") self.Admin = Administrator("*****@*****.**", "AdministratorPassword") self.Inst = Instructor("*****@*****.**", "InstructorPassword") self.Inst2 = Instructor("*****@*****.**", "InstructorPassword2") self.TA = TA("*****@*****.**", "TAPassword") self.Course1 = Course("SomeCSClass1", 1) self.Course2 = Course("SomeCSClass2", 2) self.Course3 = Course("SomeCSClass3", 3)
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]")
def test_change_name(self): self.Instructor1 = Instructor("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.Instructor1.change_name("Snoop Doggy Dog") model_person1 = models.ModelPerson.objects.get( email=self.Instructor1.email) self.assertEquals(model_person1.name, "Snoop Doggy Dog") self.assertEquals(self.Instructor1.name, "Snoop Doggy Dog") self.assertNotEquals(self.Instructor1.name, "DEFAULT")
def test_change_phone(self): self.Instructor1 = Instructor("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.Instructor1.change_phone("414.414.4141") model_person1 = models.ModelPerson.objects.get( email=self.Instructor1.email) self.assertEquals(model_person1.phone, "414.414.4141") self.assertEquals(self.Instructor1.phone_number, "414.414.4141") self.assertNotEquals(self.Instructor1.phone_number, "000.000.0000") self.assertFalse(self.Instructor1.change_phone("1234567890")) self.assertFalse(self.Instructor1.change_phone("414-414-4141")) self.assertFalse(self.Instructor1.change_phone("(414)414-4141")) self.assertFalse(self.Instructor1.change_phone("abc.abc.abcd")) self.assertFalse(self.Instructor1.change_phone("1234.1234.1234"))
def test_change_email(self): self.Instructor1 = Instructor("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.person2 = Person("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.Instructor1.change_email("*****@*****.**") model_person1 = models.ModelPerson.objects.get( email=self.Instructor1.email) self.assertEquals(model_person1.email, "*****@*****.**") self.assertEquals(self.Instructor1.email, "*****@*****.**") self.assertNotEquals(self.Instructor1.email, "*****@*****.**") self.assertFalse(self.Instructor1.change_email("*****@*****.**")) self.assertFalse( self.Instructor1.change_email("no_at_symbol_or_dot_something")) self.assertFalse(self.Instructor1.change_email("*****@*****.**"))
def view_ta_assign(self, parse_cmd): current_user = self.whos_logged_in() if len(parse_cmd) != 1: return "View TA assignments not of the right format: [view_ta_assign]" if current_user.type == "ta": tee_ayy = TA(current_user.email, current_user.password, current_user.type) return tee_ayy.view_ta_assignments() if current_user.type == "instructor": instructor = Instructor(current_user.email, current_user.password, current_user.type) return instructor.view_ta_assign() else: return "You don't have access to that command."
def test_access_info_inst_no_course(self): # Add instructor, no course assignments self.inst1 = Instructor("*****@*****.**", "password", "instructor") access_info = self.ad1.access_info() parse_info = access_info.split("\n") self.assertEqual(parse_info[7], "DEFAULT | [email protected] | 000.000.0000")
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 setUp(self): self.SUP = Supervisor("*****@*****.**", "SUP") self.ADMIN = Administrator("*****@*****.**", "ADMIN") self.INS = Instructor("*****@*****.**", "INS") self.TA = TA("*****@*****.**", "TA") """
def create_account(self, email, password, account_type): # Jeff's method # Usage: (string: email, string: password, string: account_type) # returns True if account successfully created in DB # returns False if account was unable to be created # throws exceptions if you do it wrong if account_type != "instructor" and account_type != "ta": return False try: find_email = models.ModelPerson.objects.get(email=email) except models.ModelPerson.DoesNotExist: find_email = "none" if find_email != "none": return False parse_at = email.split("@") try: if len(parse_at) != 2 or parse_at[1] != "uwm.edu": return False except IndexError: return False if account_type == "instructor": new_instructor = Instructor(email, password, "instructor") return True elif account_type == "ta": new_ta = TA(email, password, "ta") return True
def test_assign_instructor_course(self): # fake instructors self.ins1 = Instructor("*****@*****.**", "blah", "instructor") self.ins2 = Instructor("*****@*****.**", "inspass", "instructor") # fake course self.course1 = Course("CS101", 2) self.course2 = Course("CS202", 0) # instructor 1 is assigned CS101 self.assertTrue(self.sup1.assign_instructor(self.ins1, self.course1)) # self.assertEqual(self.ins1.courses[0], self.course1) self.assertEqual(self.course1.instructor.email, "*****@*****.**") # assign instructor 1 another course self.assertTrue(self.sup1.assign_instructor(self.ins1, self.course2)) # self.assertEqual(self.ins1.courses[1], self.course2) self.assertEqual(self.course2.instructor.email, "*****@*****.**") # instructor 2 is assigned CS101 self.assertTrue(self.sup1.assign_instructor(self.ins2, self.course1)) # self.assertEqual(self.ins2.courses[0], self.course1) self.assertEqual(self.course1.instructor.email, "*****@*****.**") # self.assertNotEqual(self.ins1.courses[0], self.course1) self.ta1 = TA("*****@*****.**", "beh", "TA") with self.assertRaises(TypeError): self.sup1.assign_instructor(self.ta1, self.course1) self.admin1 = Administrator("*****@*****.**", "admin1", "administrator") with self.assertRaises(TypeError): self.sup1.assign_instructor(self.admin1, self.course1) with self.assertRaises(TypeError): self.sup1.assign_instructor(self.sup1, self.course1) with self.assertRaises(AttributeError): self.sup1.assign_instructor(self.ins1, "CS301-111") with self.assertRaises(AttributeError): self.sup1.assign_instructor("*****@*****.**", self.course1) self.sup1.create_course("CS337-401", 3) da_course = models.ModelCourse.objects.get(course_id="CS337-401") # self.test_course = Course(da_course.course_id, da_course.num_labs) # self.sup.assign_instructor(self.ins1, self.test_course) da_courseaa = models.ModelCourse.objects.get(course_id="CS337-401") self.assertEquals(da_courseaa.num_labs, da_course.num_labs) self.assertEquals(da_courseaa.course_id, da_course.course_id)
def setUp(self): self.SUP = Supervisor("*****@*****.**", "SUP") self.ADMIN = Administrator("*****@*****.**", "ADMIN") self.INS = Instructor("*****@*****.**", "INS") self.TA = TA("*****@*****.**", "TA") self.Course1 = Course("CS351", 3) self.Course2 = Course("CS431", 2) self.Course3 = Course("CS361", 3)
def test_assign_ta_lab_not_ta(self): # test against non-TAs self.SUP = Supervisor("*****@*****.**", "SUP") self.ADMIN = Administrator("*****@*****.**", "ADMIN") self.INS = Instructor("*****@*****.**", "INS") self.assertEqual(self.ui.command("assign_ta_lab [email protected] 801"), "Error: [email protected] is not a TA") self.assertEqual(self.ui.command("assign_ta_lab [email protected] 801"), "Error: [email protected] is not a TA") self.assertEqual(self.ui.command("assign_ta_lab [email protected] 801"), "Error: [email protected] is not a TA")
def setUp(self): # self.instructor1 = Instructor("*****@*****.**", "DEFAULT_PASSWORD") # self.instructor2 = Instructor("*****@*****.**", "DEFAULT_PASSWORD") # fake TA # self.ta1 = ("*****@*****.**", "DEFAULT_PASSWORD") # self.ta2 = ("*****@*****.**", "DEFAULT_PASSWORD") # fake Course # self.course1 = ("Course 1", 2, self.instructor1, [self.ta1]) # self.course2 = ("Course 2", 2, self.instructor2, [self.ta2]) self.inst0 = Instructor("*****@*****.**", "password", "instructor") 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)
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")
def setUp(self): self.TA1 = TA("*****@*****.**", "ta1Pass") self.TA2 = TA("*****@*****.**", "ta2Pass") self.TA3 = TA("*****@*****.**", "ta3Pass") self.INS = Instructor("*****@*****.**", "insPass") self.SUP = Supervisor("*****@*****.**", "supPass") self.ADMIN = Administrator("*****@*****.**", "adminPass") self.COURSE1 = Course("CS101", 2) self.COURSE2 = Course("CS222", 2)
def test_assign_ta_course(self): # TA 1 is assigned CS101 # fake instructors self.ta1 = TA("*****@*****.**", "blah", "ta") self.ta2 = TA("*****@*****.**", "inspass", "ta") self.ta3 = TA("*****@*****.**", "pass3", "ta") # fake course self.course1 = Course("CS101-301", 2) self.course2 = Course("CS202-201", 0) # instructor 1 is assigned CS101 self.assertTrue(self.sup1.assign_ta_course(self.ta1, self.course1)) # self.assertEqual(self.course1.tee_ays[0], "*****@*****.**") db_ta_course = models.ModelTACourse.objects.get(course=models.ModelCourse.objects.get(course_id="CS101-301"), TA=models.ModelPerson.objects.get(email="*****@*****.**")) self.assertEqual(db_ta_course.TA, models.ModelPerson.objects.get(email="*****@*****.**")) self.assertEqual(db_ta_course.course, models.ModelCourse.objects.get(course_id="CS101-301")) # assign TA 1 another course self.assertTrue(self.sup1.assign_ta_course(self.ta1, self.course2)) #self.assertEqual(self.course1.tee_ays[0], "*****@*****.**") db_ta_course = models.ModelTACourse.objects.get(course=models.ModelCourse.objects.get(course_id="CS202-201"), TA=models.ModelPerson.objects.get(email="*****@*****.**")) self.assertEqual(db_ta_course.TA, models.ModelPerson.objects.get(email="*****@*****.**")) self.assertEqual(db_ta_course.course, models.ModelCourse.objects.get(course_id="CS202-201")) # TA 2 is assigned CS101 self.assertTrue(self.sup1.assign_ta_course(self.ta2, self.course1)) #self.assertEqual(self.course1.tee_ays[0], "*****@*****.**") db_ta_course = models.ModelTACourse.objects.get(course=models.ModelCourse.objects.get(course_id="CS101-301"), TA=models.ModelPerson.objects.get(email="*****@*****.**")) self.assertEqual(db_ta_course.TA, models.ModelPerson.objects.get(email="*****@*****.**")) self.assertEqual(db_ta_course.course, models.ModelCourse.objects.get(course_id="CS101-301")) # Try to assign a third TA to CS101 self.assertTrue(self.sup1.assign_ta_course(self.ta3, self.course1)) #self.assertEqual(self.course1.tee_ays[0], "*****@*****.**") db_ta_course = models.ModelTACourse.objects.get(course=models.ModelCourse.objects.get(course_id="CS101-301"), TA=models.ModelPerson.objects.get(email="*****@*****.**")) self.assertEqual(db_ta_course.TA, models.ModelPerson.objects.get(email="*****@*****.**")) self.assertEqual(db_ta_course.course, models.ModelCourse.objects.get(course_id="CS101-301")) self.admin1 = Administrator("*****@*****.**", "admin1", "administrator") with self.assertRaises(TypeError): self.sup1.assign_ta_course(self.admin1, self.course1) with self.assertRaises(TypeError): self.sup1.assign_ta_course(self.sup1, self.course1) self.ins1 = Instructor("*****@*****.**", "ins11111", "instructor") with self.assertRaises(TypeError): self.sup1.assign_ta_course(self.ins1, self.course1) with self.assertRaises(AttributeError): self.sup1.assign_ta_course(self.ta1, "CS301-111") with self.assertRaises(AttributeError): self.sup1.assign_ta_course("*****@*****.**", self.course1)
def test_access_info_inst_one_course(self): # Instructor with a course self.inst1 = Instructor("*****@*****.**", "password", "instructor") self.course1 = Course("CS101", 0) self.course1.instructor = "*****@*****.**" mod_course1 = models.ModelCourse.objects.get(course_id="CS101") mod_course1.instructor = "*****@*****.**" mod_course1.save() access_info = self.sup1.access_info() parse_info = access_info.split("\n") self.assertEqual(parse_info[8], "\tCourse: CS101")
def create_account(self, email, password, account_type): parse_at_symbol = email.split("@") parse_period = parse_at_symbol[1].split(".") if parse_period[0] != "uwm": return "Email address must be a UWM address." if account_type == "instructor": new_instructor = Instructor(email, password) return new_instructor elif account_type == "ta": new_ta = TA(email, password) return new_ta return "Not a valid account type for creation."
class TestInstructor(TestCase): def setup(self): self.instructor1 = Instructor("*****@*****.**", "DEFAULT_PASSWORD") self.instructor2 = Instructor("*****@*****.**", "DEFAULT_PASSWORD") # fake TA self.ta1 = ("*****@*****.**", "DEFAULT_PASSWORD") self.ta2 = ("*****@*****.**", "DEFAULT_PASSWORD") # fake Course self.course1 = ("Course 1", 2, self.instructor1, [self.ta1]) self.course2 = ("Course 2", 2, self.instructor2, [self.ta2]) def test___init__(self): self.assertEquals(self.instructor1.email, "DEFAULT_EMAIL") self.assertEquals(self.instructor1.password, "DEFAULT_PASSWORD") self.assertEquals(self.instructor1.name, "DEFAULT") self.assertEquals(self.instructor1.phone_number, "DEFAULT") def test_edit_contact(self): # still using instructor1 self.instructor1.edit_contact_info("name", "Bob Ross") self.assertNotEquals(self.instructor1.name, "DEFAULT") self.assertEquals(self.instructor1.name, "Bob Ross") self.instructor1.edit_contact_info("phone", "4145459999") self.assertNotEquals(self.instructor1.phone_number, "0000000000") self.assertEquals(self.instructor1.phone_number, "4145459999") self.instructor1.edit_contact_info("email", "*****@*****.**") self.assertNotEquals(self.instructor1.email, "*****@*****.**") self.assertEquals(self.instructor1.email, "*****@*****.**") with self.assertRaises(TypeError): self.instructor1.edit_contact_info(2, "Ted") with self.assertRaises(TypeError): self.instructor1.edit_contact_info("name", 41.6) def test_read_public_contact(self): self.assertNotEquals(self.instructor1.read_public_contact(), "DEFAULT, [email protected]") self.assertEquals(self.instructor1.read_public_contact(), "Bob Ross, [email protected]") def test_send_notification_ta(self): self.assertTrue(self.instructor1.send_notification_ta("Hi!")) def test_view_course(self): self.assertEquals(self.instructor1.view_course_assign(), "Course 1") self.assertNotEquals(self.instructor1.view_course_assign(), "Course 2") def test_view_ta_assign(self): self.assertEquals(self.instructor1.view_ta_assign()[0], self.ta1) self.assertNotEquals(self.instructor1.view_ta_assign(), self.ta2)
class TestInstructor(TestCase): def setUp(self): # self.instructor1 = Instructor("*****@*****.**", "DEFAULT_PASSWORD") # self.instructor2 = Instructor("*****@*****.**", "DEFAULT_PASSWORD") # fake TA # self.ta1 = ("*****@*****.**", "DEFAULT_PASSWORD") # self.ta2 = ("*****@*****.**", "DEFAULT_PASSWORD") # fake Course # self.course1 = ("Course 1", 2, self.instructor1, [self.ta1]) # self.course2 = ("Course 2", 2, self.instructor2, [self.ta2]) self.inst0 = Instructor("*****@*****.**", "password", "instructor") 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___init__(self): self.assertEquals(self.instructor1.email, "DEFAULT_EMAIL") self.assertEquals(self.instructor1.password, "DEFAULT_PASSWORD") self.assertEquals(self.instructor1.name, "DEFAULT") self.assertEquals(self.instructor1.phone_number, "DEFAULT") def test_edit_contact(self): # still using instructor1 self.instructor1.edit_contact_info("name", "Bob Ross") self.assertNotEquals(self.instructor1.name, "DEFAULT") self.assertEquals(self.instructor1.name, "Bob Ross") self.instructor1.edit_contact_info("phone", "4145459999") self.assertNotEquals(self.instructor1.phone_number, "0000000000") self.assertEquals(self.instructor1.phone_number, "4145459999") self.instructor1.edit_contact_info("email", "*****@*****.**") self.assertNotEquals(self.instructor1.email, "*****@*****.**") self.assertEquals(self.instructor1.email, "*****@*****.**") with self.assertRaises(TypeError): self.instructor1.edit_contact_info(2, "Ted") with self.assertRaises(TypeError): self.instructor1.edit_contact_info("name", 41.6) def test_read_public_contact(self): self.assertNotEquals(self.instructor1.read_public_contact(), "DEFAULT, [email protected]") self.assertEquals(self.instructor1.read_public_contact(), "Bob Ross, [email protected]") def test_send_notification_ta(self): self.assertTrue(self.instructor1.send_notification_ta("Hi!")) def test_view_course(self): self.assertEquals(self.instructor1.view_course_assign(), "Course 1") self.assertNotEquals(self.instructor1.view_course_assign(), "Course 2") def test_view_ta_assign1(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.inst0.view_ta_assign()[0], "Course: CS101 TA: DEFAULT, [email protected]") def test_view_ta_assign2(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.inst0.view_ta_assign()[0], "Course: CS201 TA: DEFAULT, [email protected]") def test_view_ta_assign3(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.inst0.view_ta_assign()[0], "Course: CS301 TA: DEFAULT, [email protected]") def test_view_ta_assign4(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.inst0.view_ta_assign()[0], "Course: CS101 TA: DEFAULT, [email protected]") self.assertEqual(self.inst0.view_ta_assign()[1], "Course: CS201 TA: DEFAULT, [email protected]") self.assertEqual(self.inst0.view_ta_assign()[2], "Course: CS301 TA: DEFAULT, [email protected]") self.assertEqual(self.inst0.view_ta_assign(), [ 'Course: CS101 TA: DEFAULT, [email protected]', 'Course: CS201 TA: DEFAULT, [email protected]', 'Course: CS301 TA: DEFAULT, [email protected]' ]) def test_change_password(self): self.Instructor1 = Instructor("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.assertTrue(self.Instructor1.change_password("password")) self.assertEquals(self.Instructor1.password, "password") self.assertNotEquals(self.Instructor1.password, "DEFAULT_PASSWORD") model_person1 = models.ModelPerson.objects.get( email=self.Instructor1.email) self.assertEquals(model_person1.password, "password") def test_change_email(self): self.Instructor1 = Instructor("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.person2 = Person("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.Instructor1.change_email("*****@*****.**") model_person1 = models.ModelPerson.objects.get( email=self.Instructor1.email) self.assertEquals(model_person1.email, "*****@*****.**") self.assertEquals(self.Instructor1.email, "*****@*****.**") self.assertNotEquals(self.Instructor1.email, "*****@*****.**") self.assertFalse(self.Instructor1.change_email("*****@*****.**")) self.assertFalse( self.Instructor1.change_email("no_at_symbol_or_dot_something")) self.assertFalse(self.Instructor1.change_email("*****@*****.**")) def test_change_phone(self): self.Instructor1 = Instructor("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.Instructor1.change_phone("414.414.4141") model_person1 = models.ModelPerson.objects.get( email=self.Instructor1.email) self.assertEquals(model_person1.phone, "414.414.4141") self.assertEquals(self.Instructor1.phone_number, "414.414.4141") self.assertNotEquals(self.Instructor1.phone_number, "000.000.0000") self.assertFalse(self.Instructor1.change_phone("1234567890")) self.assertFalse(self.Instructor1.change_phone("414-414-4141")) self.assertFalse(self.Instructor1.change_phone("(414)414-4141")) self.assertFalse(self.Instructor1.change_phone("abc.abc.abcd")) self.assertFalse(self.Instructor1.change_phone("1234.1234.1234")) def test_change_name(self): self.Instructor1 = Instructor("*****@*****.**", "DEFAULT_PASSWORD", "DEFAULT") self.Instructor1.change_name("Snoop Doggy Dog") model_person1 = models.ModelPerson.objects.get( email=self.Instructor1.email) self.assertEquals(model_person1.name, "Snoop Doggy Dog") self.assertEquals(self.Instructor1.name, "Snoop Doggy Dog") self.assertNotEquals(self.Instructor1.name, "DEFAULT")
def setup(self): self.Sup = Supervisor("*****@*****.**", "SupervisorPassword") self.Admin = Administrator("*****@*****.**", "AdministratorPassword") self.Inst = Instructor("*****@*****.**", "InstructorPassword") self.TA = TA("*****@*****.**", "TAPassword")
def setup(self): self.TA = TA("*****@*****.**", "taPass") self.INS = Instructor("*****@*****.**", "insPass") self.SUP = Supervisor("*****@*****.**", "supPass") self.ADMIN = Administrator("*****@*****.**", "adminPass")