Debian Codegraph @

tests/test_models_report_attribute.py

raw symbols SCIP
1 import logging
2
3 import pytest
4
5 from pbcommand.models.report import Attribute, PbReportError
6
7 log = logging.getLogger(__name__)
8
9
10 class TestAttribute:
11
12 def test_attribute_null_id(self):
13 """Can't create an attribute without an id."""
14 def _test():
15 a = Attribute(None, 1)
16
17 with pytest.raises(PbReportError):
18 _test()
19
20 def test_attribute_int_id(self):
21 """Test exception of handling Attribute with int ids"""
22 def _test():
23 a = Attribute(1, 12345)
24
25 with pytest.raises(PbReportError):
26 _test()
27
28 def test_to_dict(self):
29 """
30 Test attribute to_dict function
31 """
32 a = Attribute('bob', 123, "Bob is the name")
33 d = a.to_dict()
34 assert 'bob' == d['id']
35 assert 123 == d['value']
36 assert 'Bob is the name' == d['name']
37
38 def test_eq(self):
39 a = Attribute('a', 1234, "My Attribute")
40 b = Attribute('b', 1234, "My B Attribute")
41 c = Attribute('a', 1234, "My Attribute")
42 assert a == c
43 assert a != b
44 assert b != c
45
46 def test_repr(self):
47 a = Attribute('a', 1234, "My Attribute")
48 log.info(repr(a))
49 assert repr(a) is not None