forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_validators.py
More file actions
executable file
·34 lines (22 loc) · 916 Bytes
/
Copy pathtest_validators.py
File metadata and controls
executable file
·34 lines (22 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pytest
from ..functions.input_validators import *
# This class tests the password strength functions in 'input_validators.py'
class TestPasswordValidators:
# These functions test the length requirement validator
def test_valid_password_length(self):
valid_pass = 'ThisIsAVa1idPassword!'
assert is_strong_password(valid_pass)
def test_invalid_password_length(self):
invalid_pass = '2short'
assert not is_strong_password(invalid_pass)
def test_empty_password_length(self):
invalid_pass = ''
assert not is_strong_password(invalid_pass)
# This class tests the input cleansing function in 'input_validators.py'
class TestInputCleanser:
def test_whitespace_strip(self):
output_string = cleanse_input(' strip-whitespaces ')
assert output_string == 'strip-whitespaces'
def test_html_specials(self):
output_string = cleanse_input('<!>')
assert output_string == '<!>'