-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #365 from digitalocean/config-conftext-diff
Deepcopy in _parse_values
- Loading branch information
Showing
2 changed files
with
42 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}) |