Skip to content

Commit 397bf65

Browse files
author
zmoody
committed
update fixture and add test for custom selection serialization
1 parent 7c8e2ef commit 397bf65

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

tests/fixtures/dcim/site.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
"contact_email": "",
1414
"comments": "",
1515
"custom_fields": {
16-
"test_custom": "Hello"
16+
"test_custom": "Hello",
17+
"test_selection": {
18+
"value": 2,
19+
"label": "second"
20+
}
1721
},
1822
"count_prefixes": 2,
1923
"count_vlans": 1,

tests/test_dcim.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class SiteTestCase(unittest.TestCase, GenericTest):
282282
'pynetbox.lib.query.requests.get',
283283
return_value=Response(fixture='dcim/site.json')
284284
)
285-
def test_modify(self, mock):
285+
def test_modify_custom(self, mock):
286286
'''Test modifying a custom field.
287287
'''
288288
ret = getattr(nb, self.name).get(1)
@@ -293,6 +293,23 @@ def test_modify(self, mock):
293293
ret.custom_fields['test_custom'], 'Testing'
294294
)
295295

296+
@patch(
297+
'pynetbox.lib.query.requests.get',
298+
return_value=Response(fixture='dcim/site.json')
299+
)
300+
def test_custom_selection_serializer(self, _):
301+
'''Test that serializer with custom selection fields.
302+
'''
303+
ret = getattr(nb, self.name).get(1)
304+
ret.custom_fields['test_custom'] = "Testing"
305+
test = ret.serialize()
306+
from pprint import pprint
307+
pprint(test)
308+
self.assertEqual(
309+
test['custom_fields']['test_selection'],
310+
2
311+
)
312+
296313
@patch(
297314
'pynetbox.lib.query.requests.post',
298315
return_value=Response(fixture='dcim/site.json')

0 commit comments

Comments
 (0)