52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
from django.test import Client
|
|
from django.urls import reverse
|
|
import pytest
|
|
from pytest_django import asserts
|
|
|
|
|
|
def test_index():
|
|
c = Client()
|
|
response = c.get(reverse('home:index'))
|
|
|
|
assert response.status_code == 200
|
|
asserts.assertTemplateUsed(response, 'home/index.html')
|
|
|
|
|
|
def test_cv():
|
|
c = Client()
|
|
response = c.get(reverse('home:cv'))
|
|
|
|
assert response.status_code == 200
|
|
asserts.assertTemplateUsed(response, 'home/cv.html')
|
|
|
|
|
|
def test_service():
|
|
c = Client()
|
|
response = c.get(reverse('home:service'))
|
|
|
|
assert response.status_code == 200
|
|
asserts.assertTemplateUsed(response, 'home/service.html')
|
|
|
|
|
|
def test_contact():
|
|
c = Client()
|
|
response = c.get(reverse('home:contact'))
|
|
|
|
assert response.status_code == 200
|
|
asserts.assertTemplateUsed(response, 'home/contact.html')
|
|
|
|
|
|
def test_contact_submit_valid():
|
|
c = Client()
|
|
data = {"full_name": "foo bar", "email": "foo@bar.com", "subject": "test", "message": "test"}
|
|
response = c.post(reverse('home:contact'), data=data)
|
|
asserts.assertRedirects(response, reverse('home:contact_valid'))
|
|
|
|
|
|
def test_contact_submit_invalid():
|
|
c = Client()
|
|
data = {"bad": "form"}
|
|
response = c.post(reverse('home:contact'), data=data)
|
|
assert response.status_code == 200
|
|
|