def test_submit_profile_edit_schedule_valid(self): request = self.request_factory.post( reverse('submit'), { 'Name': ['Jim'], 'Year': ['2021'], 'Major': ['Systems Engineering'], 'NumClass': ['2'], 'phone': ['6451827384'], 'generate-schedule': [''] }) # Indicates edit schedule was pressed request.user = self.user # Create a Student Object so that it is an existing user student = Student(user=self.user, name="Borja", year=1, major="Computer Science", num=5, phone=8172229876) student.save() actual = len(submit_profile(request).content) print(submit_profile(request)) num = [1, 1] expected = len( render(request, 'studentprofile/schedule.html', { 'numC': num }).content) self.assertEqual(actual, expected)
def test_submit_profile_edit_save_valid(self): request = self.request_factory.post( reverse('submit'), { 'Name': ['Jim'], 'Year': ['2021'], 'Major': ['Systems Engineering'], 'NumClass': ['2'], 'phone': ['6451827384'], 'save-profile': [''] }) request.user = self.user # Create a Student Object so that it is an existing user student = Student(user=self.user, name="Borja", year=1, major="Computer Science", num=5, phone=8172229876) student.save() actual = len(submit_profile(request).content) print(submit_profile(request)) num = [1, 1] expected = len( HttpResponseRedirect(reverse('student profile')).content) self.assertEqual(actual, expected)
def test_submit_phone_error(self): request = self.request_factory.post( reverse('submit'), { 'Name': ['Jim'], 'Year': ['2021'], 'Major': ['Systems Engineering'], 'NumClass': ['2'], 'phone': ['645-182-7384'], 'save-profile': [''] }) request.user = self.user # Create a Student Object so that it is an existing user student = Student(user=self.user, name="Borja", year=1, major="Computer Science", num=5, phone=8172229876) student.save() actual = len(submit_profile(request).content) expected = len( render( request, 'studentprofile.html', { 'error_message': "Phone numbers must be 10-digits with no special characters", 'get_majors': majors, }).content) self.assertEqual(actual, expected)
def test_submit_profile_edit_no_name(self): request = self.request_factory.post( reverse('submit'), { 'Name': [''], 'Year': ['2021'], 'Major': ['Systems Engineering'], 'NumClass': ['2'], 'phone': ['6451827384'], 'save-profile': [''] }) request.user = self.user # Create a Student Object so that it is an existing user student = Student(user=self.user, name="Borja", year=1, major="Computer Science", num=5, phone=8172229876) student.save() actual = len(submit_profile(request).content) expected = len( render(request, 'studentprofile.html', { 'error_message': "Username cannot be blank.", 'get_majors': majors }).content) self.assertEqual(actual, expected)
def test_submit_profile_first_time_valid(self): request = self.request_factory.post( reverse('submit'), { 'Name': ['Jim'], 'Year': ['2021'], 'Major': ['Systems Engineering'], 'NumClass': ['2'], 'phone': ['6451827384'], 'generate-schedule': [''] }) # Generate Schedule request.user = self.user actual = len(submit_profile(request).content) num = [1, 1] expected = len( render(request, 'studentprofile/schedule.html', { 'numC': num }).content) self.assertEqual(actual, expected)
def test_submit_profile_first_time_no_name(self): request = self.request_factory.post( reverse('submit'), { 'Name': [''], 'Year': ['2021'], 'Major': ['Systems Engineering'], 'NumClass': ['2'], 'phone': ['6451827384'], 'generate-schedule': [''] }) request.user = self.user actual = len(submit_profile(request).content) num = [1, 1] expected = len( render( request, 'studentprofile.html', { 'error_message': "Username cannot be blank.", 'get_majors': majors, }).content) self.assertEqual(actual, expected)