Ejemplo n.º 1
0
    def test_estates_page_displays_all_list_estates(self):
        Estate.objects.create(address = 'Üks')
        Estate.objects.create(address = 'Kaks')

        request = HttpRequest()
        response = estates_page(request)

        self.assertIn('Üks', response.content.decode())
        self.assertIn('Kaks', response.content.decode())
Ejemplo n.º 2
0
    def test_estates_page_redirects_after_POST(self):
        request = HttpRequest()
        request.method = 'POST'
        request.POST['estate_address'] = 'Address 33'

        response = estates_page(request)

        self.assertEqual(response.status_code, 302)
        self.assertEqual(response['location'], '/estates/')
Ejemplo n.º 3
0
    def test_estates_page_can_save_a_POST_request(self):
        request = HttpRequest()
        request.method = 'POST'
        request.POST['estate_address'] = 'Estate 1'

        response = estates_page(request)

        self.assertEqual(Estate.objects.count(), 1)
        new_estate = Estate.objects.first()
        self.assertEqual(new_estate.address, 'Estate 1')
Ejemplo n.º 4
0
 def test_estate_page_returns_correct_html(self):
     request = HttpRequest()
     response = estates_page(request)
     expected_html = render_to_string('estates.html')
     self.assertEqual(response.content.decode(), expected_html)
Ejemplo n.º 5
0
 def test_estate_page_save_estate_only_when_necessary(self):
     request = HttpRequest()
     response = estates_page(request)
     self.assertEqual(Estate.objects.count(), 0)