Skip to content

Commit c0a81de

Browse files
author
Zach Moody
committed
Add unit tests for Extras model
1 parent 7c4d26a commit c0a81de

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/unit/test_extras.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import unittest
2+
3+
import six
4+
5+
from pynetbox.models.extras import ConfigContexts
6+
7+
8+
class ExtrasTestCase(unittest.TestCase):
9+
def test_config_contexts(self):
10+
test_values = {
11+
"data": {"test_int": 123, "test_str": "testing", "test_list": [1, 2, 3],}
12+
}
13+
test = ConfigContexts(test_values, None, None)
14+
self.assertTrue(test)
15+
16+
def test_config_contexts_diff_str(self):
17+
test_values = {
18+
"data": {
19+
"test_int": 123,
20+
"test_str": "testing",
21+
"test_list": [1, 2, 3],
22+
"test_dict": {"foo": "bar"},
23+
}
24+
}
25+
test = ConfigContexts(test_values, None, None)
26+
test.data["test_str"] = "bar"
27+
self.assertEqual(test._diff(), {"data"})
28+
29+
def test_config_contexts_diff_dict(self):
30+
test_values = {
31+
"data": {
32+
"test_int": 123,
33+
"test_str": "testing",
34+
"test_list": [1, 2, 3],
35+
"test_dict": {"foo": "bar"},
36+
}
37+
}
38+
test = ConfigContexts(test_values, None, None)
39+
test.data["test_dict"].update({"bar": "foo"})
40+
self.assertEqual(test._diff(), {"data"})

0 commit comments

Comments
 (0)