Ejemplo n.º 1
0
 def test_home_page_shows_two_semesters(self):
     self.create_two_semesters_for_unit_tests()
     request = HttpRequest()
     Bob = User.objects.get(username='******')
     request.user = Bob
     response = home_page(request)
     self.assertEqual(Semester.objects.count(), 2)
Ejemplo n.º 2
0
 def test_home_page_template_has_two_semesters(self):
     self.create_two_semesters_for_unit_tests()
     request = HttpRequest()
     Bob = User.objects.get(username='******')
     request.user = Bob
     response = home_page(request)
     self.assertIn('201530', response.content.decode())
     self.assertIn('201610', response.content.decode())
Ejemplo n.º 3
0
 def test_home_page_returns_correct_html(self):
     self.create_two_semesters_for_unit_tests()
     request = HttpRequest()
     Bob = User.objects.get(username='******')
     request.user = Bob
     response = home_page(request)
     semesters = Semester.objects.all()
     expected_html = render_to_string('rubricapp/home.html', { 'semestercode': semesters })
     self.assertMultiLineEqual(response.content.decode(), expected_html)
Ejemplo n.º 4
0
    def test_home_page_can_redirects_after_Post_request(self):
        self.create_two_semesters_for_unit_tests()
        request = HttpRequest()
        Bob = User.objects.get(username='******')
        request.user = Bob
        request.method = 'POST'
        semester = Semester.objects.get(text="201530")
        request.POST['semester'] = semester.text

        response = home_page(request)

        self.assertEqual(response.status_code, 302)
        self.assertEqual(response['location'], '201530/')