mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-20 06:52:15 +00:00
Add a test!
Just one
This commit is contained in:
@@ -1,5 +1,19 @@
|
||||
import datetime
|
||||
import pytest
|
||||
|
||||
from django.utils import timezone
|
||||
from django.urls import reverse
|
||||
|
||||
from pytest_django.asserts import assertFormError, assertRedirects, assertContains, assertNotContains
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
from training import models
|
||||
|
||||
|
||||
def test_add_qualification(admin_client, trainee, admin_user):
|
||||
url = reverse('add_qualification', kwargs={'pk': trainee.pk})
|
||||
date = (timezone.now() + datetime.timedelta(days=3)).strftime("%Y-%m-%d")
|
||||
response = admin_client.post(url, {'date': date, 'trainee': trainee.pk, 'supervisor': trainee.pk })
|
||||
assertFormError(response, 'form', 'date', 'Qualification date may not be in the future')
|
||||
assertFormError(response, 'form', 'supervisor', 'One may not supervise oneself...')
|
||||
response = admin_client.post(url, {'date': date, 'trainee': trainee.pk, 'supervisor': admin_user.pk })
|
||||
assertFormError(response, 'form', 'supervisor', 'Selected supervisor must actually *be* a supervisor...')
|
||||
|
||||
Reference in New Issue
Block a user