Skip to content

Commit

Permalink
Add unit tests for Extras model
Browse files Browse the repository at this point in the history
  • Loading branch information
Zach Moody committed Apr 8, 2021
1 parent 7c4d26a commit c0a81de
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/unit/test_extras.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import unittest

import six

from pynetbox.models.extras import ConfigContexts


class ExtrasTestCase(unittest.TestCase):
def test_config_contexts(self):
test_values = {
"data": {"test_int": 123, "test_str": "testing", "test_list": [1, 2, 3],}
}
test = ConfigContexts(test_values, None, None)
self.assertTrue(test)

def test_config_contexts_diff_str(self):
test_values = {
"data": {
"test_int": 123,
"test_str": "testing",
"test_list": [1, 2, 3],
"test_dict": {"foo": "bar"},
}
}
test = ConfigContexts(test_values, None, None)
test.data["test_str"] = "bar"
self.assertEqual(test._diff(), {"data"})

def test_config_contexts_diff_dict(self):
test_values = {
"data": {
"test_int": 123,
"test_str": "testing",
"test_list": [1, 2, 3],
"test_dict": {"foo": "bar"},
}
}
test = ConfigContexts(test_values, None, None)
test.data["test_dict"].update({"bar": "foo"})
self.assertEqual(test._diff(), {"data"})

0 comments on commit c0a81de

Please sign in to comment.