UPD: dav_registration: tests.

This commit is contained in:
2019-05-29 16:49:05 +02:00
parent d8919f3394
commit a189f5dbe6
2 changed files with 31 additions and 21 deletions

View File

@@ -4,6 +4,7 @@ from django.apps import apps
from django.contrib.auth.models import AbstractUser
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.core import mail as django_mail
from django.core.exceptions import ValidationError
from django.test import SimpleTestCase, TestCase, tag
from django.urls import reverse
from selenium import webdriver
@@ -209,6 +210,24 @@ class UrlsTestCase(SimpleTestCase):
'Getting url named \'{}\' resolve to wrong function'.format(url.name))
class ValidatorTestMixin(object):
def assertValid(self, validator, data):
for val in data:
try:
validator(val)
except ValidationError as e: # pragma: no cover
self.fail('%s: %s' % (val, e))
def assertInvalid(self, validator, data):
for val in data:
try:
validator(val)
except ValidationError:
pass
else: # pragma: no cover
self.fail('%s: no ValidationError was raised' % val)
class SeleniumTestCase(StaticLiveServerTestCase):
headless = True
window_width = 1024