Skip to content

Commit c496db4

Browse files
committed
add tests
1 parent 5b03c6a commit c496db4

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/test/test_dp_base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ def tearDown(self) -> None:
4242
# restore the original registry
4343
base._reset_registered()
4444

45+
def test_decision_point_basics(self):
46+
from ssvc._mixins import _Base, _Keyed, _Namespaced, _Valued, _Versioned
47+
48+
# inherits from mixins
49+
mixins = [_Valued, _Base, _Keyed, _Versioned, _Namespaced]
50+
for mixin in mixins:
51+
self.assertIsInstance(self.dp, mixin)
52+
4553
def test_registry(self):
4654
# just by creating the objects, they should be registered
4755
self.assertIn(self.dp, base.REGISTERED_DECISION_POINTS)

src/test/test_mixins.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from pydantic import BaseModel, ValidationError
1717

18-
from ssvc._mixins import _Base, _Keyed, _Namespaced, _Versioned
18+
from ssvc._mixins import _Base, _Keyed, _Namespaced, _Valued, _Versioned
1919

2020

2121
class TestMixins(unittest.TestCase):
@@ -88,6 +88,22 @@ def test_keyed_create(self):
8888

8989
self.assertRaises(ValidationError, _Keyed)
9090

91+
def test_valued_create(self):
92+
values = ("foo", "bar", "baz", "quux")
93+
obj = _Valued(values=values)
94+
95+
# length
96+
self.assertEqual(len(obj), len(values))
97+
98+
# iteration
99+
for i, v in enumerate(obj):
100+
self.assertEqual(v, values[i])
101+
102+
# values
103+
self.assertEqual(obj.values, values)
104+
105+
self.assertRaises(ValidationError, _Valued)
106+
91107
def test_mixin_combos(self):
92108
# We need to test all the combinations
93109
mixins = [
@@ -103,9 +119,7 @@ def test_mixin_combos(self):
103119
"has_default": True,
104120
},
105121
]
106-
keys_with_defaults = [
107-
x["args"].keys() for x in mixins if x["has_default"]
108-
]
122+
keys_with_defaults = [x["args"].keys() for x in mixins if x["has_default"]]
109123
# flatten the list
110124
keys_with_defaults = [
111125
item for sublist in keys_with_defaults for item in sublist

0 commit comments

Comments
 (0)