2020-02-03 17:25:54 +00:00
|
|
|
import unittest
|
|
|
|
|
2022-10-14 14:53:06 +00:00
|
|
|
from benedict.core import unique as _unique
|
|
|
|
|
2020-02-03 17:25:54 +00:00
|
|
|
|
|
|
|
class unique_test_case(unittest.TestCase):
|
2022-02-13 10:35:43 +00:00
|
|
|
"""
|
|
|
|
This class describes an unique test case.
|
|
|
|
"""
|
2020-02-03 17:25:54 +00:00
|
|
|
|
|
|
|
def test_unique(self):
|
|
|
|
d = {
|
2022-02-13 10:35:43 +00:00
|
|
|
"a": {
|
|
|
|
"x": 1,
|
|
|
|
"y": 1,
|
2020-02-03 17:25:54 +00:00
|
|
|
},
|
2022-02-13 10:35:43 +00:00
|
|
|
"b": {
|
|
|
|
"x": 2,
|
|
|
|
"y": 2,
|
2020-02-03 17:25:54 +00:00
|
|
|
},
|
2022-02-13 10:35:43 +00:00
|
|
|
"c": {
|
|
|
|
"x": 1,
|
|
|
|
"y": 1,
|
2020-02-03 17:25:54 +00:00
|
|
|
},
|
2022-02-13 10:35:43 +00:00
|
|
|
"d": {
|
|
|
|
"x": 1,
|
2020-02-03 17:25:54 +00:00
|
|
|
},
|
2022-02-13 10:35:43 +00:00
|
|
|
"e": {
|
|
|
|
"x": 1,
|
|
|
|
"y": 1,
|
|
|
|
"z": 1,
|
2020-02-03 17:25:54 +00:00
|
|
|
},
|
2022-02-13 10:35:43 +00:00
|
|
|
"f": {
|
|
|
|
"x": 2,
|
|
|
|
"y": 2,
|
2020-02-03 17:25:54 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
_unique(d)
|
|
|
|
rv = [
|
|
|
|
{
|
2022-02-13 10:35:43 +00:00
|
|
|
"x": 1,
|
|
|
|
"y": 1,
|
2020-02-03 17:25:54 +00:00
|
|
|
},
|
|
|
|
{
|
2022-02-13 10:35:43 +00:00
|
|
|
"x": 2,
|
|
|
|
"y": 2,
|
2020-02-03 17:25:54 +00:00
|
|
|
},
|
|
|
|
{
|
2022-02-13 10:35:43 +00:00
|
|
|
"x": 1,
|
2020-02-03 17:25:54 +00:00
|
|
|
},
|
|
|
|
{
|
2022-02-13 10:35:43 +00:00
|
|
|
"x": 1,
|
|
|
|
"y": 1,
|
|
|
|
"z": 1,
|
2020-02-03 17:25:54 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
self.assertEqual(len(d.keys()), len(rv))
|
|
|
|
self.assertTrue(all([value in rv for value in d.values()]))
|