forked from xmlsec/python-xmlsec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_constants.py
42 lines (30 loc) · 1.46 KB
/
test_constants.py
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
35
36
37
38
39
40
41
42
"""Test constants from :mod:`xmlsec.constants` module."""
from hypothesis import given, strategies
import xmlsec
def _constants(typename):
return list(
sorted(
(
getattr(xmlsec.constants, name)
for name in dir(xmlsec.constants)
if type(getattr(xmlsec.constants, name)).__name__ == typename
),
key=lambda t: t.name.lower(),
)
)
@given(transform=strategies.sampled_from(_constants('__Transform')))
def test_transform_str(transform):
"""Test string representation of ``xmlsec.constants.__Transform``."""
assert str(transform) == '{}, {}'.format(transform.name, transform.href)
@given(transform=strategies.sampled_from(_constants('__Transform')))
def test_transform_repr(transform):
"""Test raw string representation of ``xmlsec.constants.__Transform``."""
assert repr(transform) == '__Transform({!r}, {!r}, {})'.format(transform.name, transform.href, transform.usage)
@given(keydata=strategies.sampled_from(_constants('__KeyData')))
def test_keydata_str(keydata):
"""Test string representation of ``xmlsec.constants.__KeyData``."""
assert str(keydata) == '{}, {}'.format(keydata.name, keydata.href)
@given(keydata=strategies.sampled_from(_constants('__KeyData')))
def test_keydata_repr(keydata):
"""Test raw string representation of ``xmlsec.constants.__KeyData``."""
assert repr(keydata) == '__KeyData({!r}, {!r})'.format(keydata.name, keydata.href)