def setUp(self): self.Client = Client() self.Client.session["position"] = "S" self.Client.session.save() # creates 3 users (user0, user1, user2) # for i in range(3): self.temp = MyUser(username="******", first_name="john", last_name="deer", position="S") self.temp.set_password(raw_password="******") self.temp.save() self.temp1 = MyUser(username="******", first_name="jim", last_name="dean", position="I") self.temp1.set_password(raw_password="******") self.temp1.save() self.temp2 = MyUser(username="******", first_name="jack", last_name="daniels", position="T") self.temp1.set_password(raw_password="******") self.temp1.save() self.data = CourseData(title="Cs") self.course = CourseSections(course=self.data, section=901) self.TA = TASkills(skills="Math")
class testCreateLab(TestCase): def setUp(self): self.Client = Client() # creates 3 users (user0, user1, user2) # for i in range(3): self.temp = MyUser(username="******", first_name="john", last_name="deer", position="S") self.temp.set_password(raw_password="******") self.temp.save() self.temp1 = MyUser(username="******", first_name="john", last_name="deer", position="T") self.temp1.set_password(raw_password="******") self.temp1.save() def test_01(self): response1 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual(reverse('home'), response1.request["PATH_INFO"], "Valid Information will take to the homepage page") response = self.client.post("/Create_Lab/", { "title": "Introduction to Software Engineering", "designation": "CS361", "semester": "Spring 2021" }, follow=True) self.assertEqual(response.request["PATH_INFO"], "/Homepage/") def test_01_Invalid(self): response1 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual(reverse('home'), response1.request["PATH_INFO"], "Valid Information will take to the homepage page") response = self.client.post( "/CreateLab/", { "title": "Introduction", "designation": "CS361", "semester": "Spring 2021" }) self.assertEqual("/CreateLab/", response.request["PATH_INFO"], "Invalid type")
def setUp(self): self.Client = Client() # creates 3 users (user0, user1, user2) # for i in range(3): self.temp = MyUser(username="******", first_name="john", last_name="deer", position="S") self.temp.set_password(raw_password="******") self.temp.save() self.temp1 = MyUser(username="******", first_name="john", last_name="deer", position="T") self.temp1.set_password(raw_password="******") self.temp1.save()
def setUp(self): self.Client = Client() self.temp1 = MyUser(username="******", first_name="john", last_name="deer", position=UserType.INSTRUCTOR) self.temp1.set_password(raw_password="******") self.temp1.save() self.ta = MyUser(username="******", position=UserType.I) self.ta.save() self.data = CourseData(title="Class", designation="CS1") self.data.save() self.course = CourseSections(course=self.data, section=901, instructor=self.temp1) self.course.save()
def setUp(self): self.Client = Client() self.Client.session["position"] = "S" self.Client.session.save() # creates 3 users (user0, user1, user2) # for i in range(3): self.temp = MyUser(username="******", first_name="john", last_name="deer", position="S") self.temp.set_password(raw_password="******") self.temp.save() self.data = CourseData(title="Cs") self.course = CourseSections(course=self.data, section=901, instructor=self.temp1) self.Lab = LabData(course=self.course, section=902)
def setUp(self): self.Client = Client() # self.Client.session["position"] = "S" # self.Client.session.save() # creates 3 users (user0, user1, user2) # for i in range(3): self.temp = MyUser(username="******", first_name="john", last_name="deer", position=UserType.SUPERVISOR) self.temp.set_password(raw_password="******") self.temp.save() self.temp1 = MyUser(username="******", first_name="john", last_name="deer", position=UserType.INSTRUCTOR) self.temp1.set_password(raw_password="******") self.temp1.save() self.ta = MyUser(username="******", position=UserType.TA) self.ta.save() self.data = CourseData(title="Class", designation="CS1") self.data.save() self.course = CourseSections(course=self.data, section=901, instructor=self.temp1) self.course.save() self.Lab = LabData(course=self.data, section=902) self.Lab.save()
def setUp(self): for i in range(3): temp = MyUser(username="******" + str(i), first_name="john" + str(i), last_name="doe" + str(i)) temp.set_password(raw_password="******" + str(i)) temp.save()
def setUp(self): self.client = Client() self.instructor_user = MyUser(position="I", username='******') self.instructor_user.set_password(raw_password='******') self.instructor_user.save() self.TA_user = MyUser(position="T", username='******') self.TA_user.set_password(raw_password='******') self.instructor_user.save() self.test_instructor_info = MyUser.objects.create( myName='Test Instructor', phoneNumber='414-555-5501', addressl1='4306 Griff Street', email='*****@*****.**', ) self.test_TA_info = MyUser.objects.create( myName='Test TA', phoneNumber='414-341-1102', addressl1='706 Offshore Drive', email='*****@*****.**', )
def setUp(self): self.Client = Client() self.Client.session["position"] = "S" self.Client.session.save() # creates 3 users (user0, user1, user2) for i in range(3): temp = MyUser(username="******" + str(i), first_name="john" + str(i), last_name="deer" + str(i)) temp.set_password(raw_password="******" + str(i)) temp.save()
def setUp(self): self.Client = Client() self.temp = MyUser(username="******", first_name="Susan", last_name="Mcroy", position=UserType.SUPERVISOR) self.temp.set_password(raw_password="******") self.temp.save() self.temp1 = MyUser(username="******", first_name="Jason", last_name="Rock", position=UserType.INSTRUCTOR) self.temp1.set_password(raw_password="******") self.temp1.save() self.temp2 = MyUser(username="******", first_name="Apoorv", last_name="Prasad", position=UserType.TA) self.temp2.set_password(raw_password="******") self.temp2.save()
class testAssignTA(TestCase): def setUp(self): self.Client = Client() # self.Client.session["position"] = "S" # self.Client.session.save() # creates 3 users (user0, user1, user2) # for i in range(3): self.temp = MyUser(username="******", first_name="john", last_name="deer", position=UserType.SUPERVISOR) self.temp.set_password(raw_password="******") self.temp.save() self.temp1 = MyUser(username="******", first_name="john", last_name="deer", position=UserType.INSTRUCTOR) self.temp1.set_password(raw_password="******") self.temp1.save() self.ta = MyUser(username="******", position=UserType.TA) self.ta.save() self.data = CourseData(title="Class", designation="CS1") self.data.save() self.course = CourseSections(course=self.data, section=901, instructor=self.temp1) self.course.save() self.Lab = LabData(course=self.data, section=902) self.Lab.save() def test_01(self): response1 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual( reverse('home'), response1.request['PATH_INFO'], "Valid Information does not take to the homepage page") response = self.Client.post( "/create_account/", { "username": "******", "password": "******", "first_name": "brett", "last_name": "frank", "addressln1": "3423 N Maryland", "addressln2": "Milwaukee wi", "title": "TA", "email": "*****@*****.**", "number": "123456789" }) self.assertEqual(response.context.get("message"), "successfully created account", msg="No message for confirmed account creation") self.assertEqual(reverse('home'), response1.request["PATH_INFO"]) # assign the user created to the course declared in setUp response2 = self.Client.post("/Create_Lab/", {"Lab": 1}, follow=True) self.assertEqual(reverse('home'), response2.request['PATH_INFO']) def test_02(self): response1 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual(reverse('home'), response1.request["PATH_INFO"], "Valid Information will take to the homepage page") response = self.Client.post( "/create_account/", { "username": "******", "password": "******", "first_name": "brett", "last_name": "frank", "addressln1": "3423 N Maryland", "addressln2": "Milwaukee WI", "title": "TA", "email": "*****@*****.**", "number": "123456789" }) self.assertEqual(response.context["message"], "successfully created account", msg="confirmed account creation") self.assertEqual(reverse('home'), response.request["PATH_INFO"]) # assign the user created to the course declared in setUp response2 = self.Client.post("/Create_Lab/", {"Lab": 2}) self.assertEqual("/Create_Lab/", response2.request["PATH_INFO"], "Lab does not exist")
class TestAddPersonalInfo(TestCase): def setUp(self): self.client = Client() self.instructor_user = MyUser(position="I", username='******') self.instructor_user.set_password(raw_password='******') self.instructor_user.save() self.TA_user = MyUser(position="T", username='******') self.TA_user.set_password(raw_password='******') self.instructor_user.save() self.test_instructor_info = MyUser.objects.create( myName='Test Instructor', phoneNumber='414-555-5501', addressl1='4306 Griff Street', email='*****@*****.**', ) self.test_TA_info = MyUser.objects.create( myName='Test TA', phoneNumber='414-341-1102', addressl1='706 Offshore Drive', email='*****@*****.**', ) # changing the phone number def test_updatePhoneNumberIN(self): # login response = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }) self.assertEqual(response.url, reverse('home'), msg="Error: logging in does not redirect properly") response = self.client.post( reverse('editself'), { "username": "******", "first_name": "Test", "last_name": "Instructor", "phone_number": "416-320-5501", "email": "*****@*****.**", "addressln1": "4306 Griff Street" }) self.pi = MyUser.objects.all() self.assertEqual( len(self.pi), 2, msg= "Error: an extra user is created when trying to update user data") user = MyUser.objects.get(username__iexact="prof01") self.assertEqual(user.phone_number, "416-320-5501") # changing email def test_updatedEmailIN(self): # login response = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }) self.assertEqual(response.url, '/Homepage/') response1 = self.client.post( reverse('editself'), { "username": "******", "first_name": "Test", "last_name": "Instructor", "phone_number": "416-555-5501", "email": "*****@*****.**", "addressln1": "4306 Griff Street" }) self.pi = MyUser.objects.all() self.assertEqual( len(self.pi), 2, msg= "Error: an extra user is created when trying to update user data") self.assertEqual(MyUser.objects.get(username="******").email, "*****@*****.**", msg="Error: email is not updated") # changing address def test_updateAddressIN(self): # login response = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }) self.assertEqual(response.url, '/Homepage/') response2 = self.client.post( reverse('editself'), { "username": "******", "first_name": "Test Instructor", "last_name": "Instructor", "phone_Number": "416-555-5501", "email": "*****@*****.**", "addressln1": "4316 Red Street" }) self.pi = MyUser.objects.all() self.assertEqual( len(self.pi), 2, msg= "Error: an extra user is created when trying to update user data") self.assertEqual(MyUser.objects.get(username="******").addressln1, "4316 Red Street", msg="Error: address is not updated") self.assertEqual(MyUser.objects.get(username="******").addressln2, "Milwaukee, WI", msg="Error: address is not updated") # changing the phone number def test_updatePhoneNumberTA(self): # login response2 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }) self.assertEqual(response2.url, '/Homepage/') response3 = self.client.post( reverse('editself'), { "username": "******", "first_name": "Test TA", "last_name": "TA", "phone_number": "414-855-2201", "email": "*****@*****.**", "addressln1": "706 Offshore Drive" }) self.pi = MyUser.objects.all() self.assertEqual( len(self.pi), 2, msg= "Error: an extra user is created when trying to update user data") user1 = MyUser.objects.get(username__iexact="TA01") self.assertEqual(user1.phone_number, "414-855-2201") # changing email def test_updatedEmailTA(self): # login response2 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }) self.assertEqual(response2.url, '/Homepage/') response4 = self.client.post( reverse('editself'), { "username": "******", "first_name": "Test TA", "last_name": "TA", "phone_number": "414-341-1102", "email": "*****@*****.**", "addressln1": "706 Offshore Drive" }) self.pi = MyUser.objects.all() self.assertEqual( len(self.pi), 2, msg= "Error: an extra user is created when trying to update user data") user1 = MyUser.objects.get(username__iexact="TA01") self.assertEqual(user1.email, "*****@*****.**") # changing address def test_updateAddressTA(self): # login response2 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }) self.assertEqual(response2.url, '/Homepage/') response5 = self.client.post( reverse('editself'), { "username": "******", "first_name": "Test TA", "last_name": "TA", "phone_number": "414-341-1102", "email": "*****@*****.**", "addressln1": "320 Blue Aster Dr" }) self.pi = MyUser.objects.all() self.assertEqual( len(self.pi), 2, msg= "Error: an extra user is created when trying to update user data") user1 = MyUser.objects.get(username__iexact="prof01") self.assertEqual(user1.addressln1, "320 Blue Aster Dr") def test_updateTASkills(self): response = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }) self.assertEqual(response.url, reverse('home'), msg="Error: logging in does not redirect properly") response1 = self.client.post( reverse('editself'), { "username": "******", "first_name": "ta", "last_name": "ta", "phone_number": "416-555-5501", "email": "*****@*****.**", "skills": "Grading" }) self.pi = MyUser.objects.all() self.assertEqual( len(self.pi), 2, msg= "Error: an extra user is created when trying to update user data") self.assertEqual(TASkills.objects.get(TA__username="******").skills, "Grading", msg="Error: skills are not updated")
class testLogin(TestCase): def setUp(self): self.Client = Client() self.temp = MyUser(username="******", first_name="Susan", last_name="Mcroy", position=UserType.SUPERVISOR) self.temp.set_password(raw_password="******") self.temp.save() self.temp1 = MyUser(username="******", first_name="Jason", last_name="Rock", position=UserType.INSTRUCTOR) self.temp1.set_password(raw_password="******") self.temp1.save() self.temp2 = MyUser(username="******", first_name="Apoorv", last_name="Prasad", position=UserType.TA) self.temp2.set_password(raw_password="******") self.temp2.save() def test_valid_login_S(self): response = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual("/Homepage/", response.request["PATH_INFO"], "Valid Information will take to the homepage page") # after a successful login it should take the user to the homescreen def test_invalid_login_S(self): response = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }) self.assertEqual("Error: incorrect password", response.context['message'], "InValid Information will take back to home page") def test_valid_login_I(self): response = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual("/Homepage/", response.request["PATH_INFO"], "Valid Information will take to the homepage page") def test_invalid_login_I(self): response = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual( "Error: incorrect password", response.context['message'], "InValid Information does not take back to home page") def test_valid_login_TA(self): response = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual("/Homepage/", response.request["PATH_INFO"], "Valid Information will take to the homepage page") def test_invalid_login_TA(self): response = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }) self.assertEqual( "Error: incorrect password", response.context['message'], "InValid Information does not take back to home page")
class testEditAccount(TestCase): def setUp(self): self.Client = Client() self.Client.session["position"] = "S" self.Client.session.save() # creates 3 users (user0, user1, user2) # for i in range(3): self.temp = MyUser(username="******", first_name="john", last_name="deer", position="S") self.temp.set_password(raw_password="******") self.temp.save() self.temp1 = MyUser(username="******", first_name="jim", last_name="dean", position="I") self.temp1.set_password(raw_password="******") self.temp1.save() self.temp2 = MyUser(username="******", first_name="jack", last_name="daniels", position="T") self.temp1.set_password(raw_password="******") self.temp1.save() self.data = CourseData(title="Cs") self.course = CourseSections(course=self.data, section=901) self.TA = TASkills(skills="Math") def test_01(self): response1 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual(reverse('home'), response1.request["PATH_INFO"], "Valid Information will take to the homepage page") def test_noAccount(self): response1 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual(reverse('home'), response1.request["PATH_INFO"], "Valid Information will take to the homepage page") response = self.Client.post("/edit_account/", { "username": "******", "password": "******", "first_name": "Bob", "last_name": "frank", "address": "3423 N Maryland", "title": "I", "email": "*****@*****.**", "number": "123456789" }, follow=True) self.assertEqual(response.context.get("message"), "successfully edited account", msg="confirmed account edit") self.assertEqual(response.url, reverse('home')) def test_AsTA(self): response2 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual(reverse('home'), response2.request["PATH_INFO"], "Valid Information will take to the homepage page") response3 = self.Client.post("/edit_account/", { "username": "******", "password": "******", "first_name": "Jack", "last_name": "Daniels", "address": "3429 N Maryland", "title": UserType.TA, "email": "*****@*****.**", "number": "123456789", "Skills": "Math" }, follow=True) self.assertEqual(response3.context.get("message"), "skills for TA updated successfully", msg="skills have not been added") def test_ASSP(self): response1 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual(reverse('home'), response1.request["PATH_INFO"], "Valid Information will take to the homepage page") response = self.Client.post("/edit_account/", { "username": "******", "password": 1234, "first_name": "Bryan", "last_name": "Johnson", "address": "3429 N Maryland", "title": "TA", "email": "*****@*****.**", "number": "123456789", }, follow=True) self.assertEqual(response.context.get("message"), "invalid credentials", msg="account was not edited") def test_accountExists(self): response = self.Client.post("/edit_account/", { "username": "******", "password": "******", "first_name": "Bryan", "last_name": "Johnson", "address": "3429 N Maryland", "title": UserType.SUPERVISOR, "email": "*****@*****.**", "number": "123456789" }, follow=True) self.assertEqual(response.context.get("message"), "account already exists", msg="account was not created") self.assertEqual(response.request["PATH_INFO"], "/create_account/")
class testCreateCourses(TestCase): def setUp(self): self.Client = Client() self.Client.session["position"] = "S" self.Client.session.save() # creates 3 users (user0, user1, user2) # for i in range(3): self.temp = MyUser(username="******", first_name="john", last_name="deer", position="S") self.temp.set_password(raw_password="******") self.temp.save() self.temp1 = MyUser(username="******", first_name="john", last_name="deer", position="I") self.temp1.set_password(raw_password="******") self.temp1.save() def test_01(self): response1 = self.client.post("/Login/", { 'username': '******', 'password': '******' }, follow=True) self.assertEqual("/Homepage/", response1.request["PATH_INFO"], "Valid Information will take to the homepage page") response = self.client.post( "/Create_Course/", { "title": "Introduction to Software Engineering", "designation": "CS361", "section": 201, "semester": "SP21" }) self.assertEqual(response.request["PATH_INFO"], "/Homepage/") # test if the account that was created above can login. If so then It was successfully created and it works response1 = self.client.post("/Login/", { 'username': '******', 'password': '******' }) def test_01_Invalid(self): response1 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual(reverse('home'), response1.request["PATH_INFO"], "Valid Information will take to the homepage page") response = self.client.post( "/Create_Course/", { "title": 12121, "section": "201", "semester": "Spring 2021", "Instructor": 1, "role": "TA", "Lab": 901 }) self.assertEqual("/Create_Course/", response.request["PATH_INFO"], "Invalid type") # test if the account that was created above can login. If so then It was succesfully created and it works self.client.get(reverse('logout'), follow=True) response1 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual("/Homepage/", response1.request["PATH_INFO"], "Valid Information will take to the homepage page")