mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 12:12:53 -06:00
Add test for dict_to_filter_params
This commit is contained in:
parent
655e48823a
commit
fd4c5031c7
@ -1,13 +1,48 @@
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from utilities.utils import deepmerge
|
from utilities.utils import deepmerge, dict_to_filter_params
|
||||||
|
|
||||||
|
|
||||||
|
class DictToFilterParamsTest(TestCase):
|
||||||
|
"""
|
||||||
|
Validate the operation of dict_to_filter_params().
|
||||||
|
"""
|
||||||
|
def setUp(self):
|
||||||
|
return
|
||||||
|
|
||||||
|
def test_dict_to_filter_params(self):
|
||||||
|
|
||||||
|
input = {
|
||||||
|
'a': True,
|
||||||
|
'foo': {
|
||||||
|
'bar': 123,
|
||||||
|
'baz': 456,
|
||||||
|
},
|
||||||
|
'x': {
|
||||||
|
'y': {
|
||||||
|
'z': False
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output = {
|
||||||
|
'a': True,
|
||||||
|
'foo__bar': 123,
|
||||||
|
'foo__baz': 456,
|
||||||
|
'x__y__z': False,
|
||||||
|
}
|
||||||
|
|
||||||
|
self.assertEqual(dict_to_filter_params(input), output)
|
||||||
|
|
||||||
|
input['x']['y']['z'] = True
|
||||||
|
|
||||||
|
self.assertNotEqual(dict_to_filter_params(input), output)
|
||||||
|
|
||||||
|
|
||||||
class DeepMergeTest(TestCase):
|
class DeepMergeTest(TestCase):
|
||||||
"""
|
"""
|
||||||
Validate the behavior of the deepmerge() utility.
|
Validate the behavior of the deepmerge() utility.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user