mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Adds test for Evennia validator.
This commit is contained in:
parent
e5828024e2
commit
35efb57b56
1 changed files with 16 additions and 0 deletions
|
|
@ -23,6 +23,9 @@ try:
|
|||
from django.utils import unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from evennia.server.validators import EvenniaPasswordValidator
|
||||
from evennia.utils.test_resources import EvenniaTest
|
||||
|
||||
from django.test.runner import DiscoverRunner
|
||||
|
||||
|
|
@ -77,3 +80,16 @@ class TestDeprecations(TestCase):
|
|||
self.assertRaises(DeprecationWarning, check_errors, MockSettings(setting))
|
||||
# test check for WEBSERVER_PORTS having correct value
|
||||
self.assertRaises(DeprecationWarning, check_errors, MockSettings("WEBSERVER_PORTS", value=["not a tuple"]))
|
||||
|
||||
class ValidatorTest(EvenniaTest):
|
||||
|
||||
def test_validator(self):
|
||||
# Validator returns None on success and ValidationError on failure.
|
||||
validator = EvenniaPasswordValidator()
|
||||
|
||||
# This password should meet Evennia standards.
|
||||
self.assertFalse(validator.validate('testpassword', user=self.account))
|
||||
|
||||
# This password contains illegal characters and should raise an Exception.
|
||||
from django.core.exceptions import ValidationError
|
||||
self.assertRaises(ValidationError, validator.validate, '(#)[#]<>', user=self.account)
|
||||
Loading…
Add table
Add a link
Reference in a new issue