2020-02-03 17:25:54 +00:00
|
|
|
import unittest
|
|
|
|
|
2022-10-14 14:53:06 +00:00
|
|
|
from benedict.core import move as _move
|
|
|
|
|
2020-02-03 17:25:54 +00:00
|
|
|
|
|
|
|
class move_test_case(unittest.TestCase):
|
2022-02-13 10:35:43 +00:00
|
|
|
"""
|
|
|
|
This class describes a move test case.
|
|
|
|
"""
|
2020-02-03 17:25:54 +00:00
|
|
|
|
|
|
|
def test_move(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": 3,
|
|
|
|
"y": 3,
|
2020-02-03 17:25:54 +00:00
|
|
|
},
|
|
|
|
}
|
2022-02-13 10:35:43 +00:00
|
|
|
_move(d, "a", "d")
|
2020-02-03 17:25:54 +00:00
|
|
|
r = {
|
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": 3,
|
|
|
|
"y": 3,
|
2020-02-03 17:25:54 +00:00
|
|
|
},
|
2022-02-13 10:35:43 +00:00
|
|
|
"d": {
|
|
|
|
"x": 1,
|
|
|
|
"y": 1,
|
2020-02-03 17:25:54 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
self.assertEqual(d, r)
|
|
|
|
|
|
|
|
def test_move_with_same_key(self):
|
|
|
|
d = {
|
2022-02-13 10:35:43 +00:00
|
|
|
"a": 1,
|
|
|
|
"b": 2,
|
2020-02-03 17:25:54 +00:00
|
|
|
}
|
2022-02-13 10:35:43 +00:00
|
|
|
_move(d, "a", "a")
|
2020-02-03 17:25:54 +00:00
|
|
|
r = {
|
2022-02-13 10:35:43 +00:00
|
|
|
"a": 1,
|
|
|
|
"b": 2,
|
2020-02-03 17:25:54 +00:00
|
|
|
}
|
|
|
|
self.assertEqual(d, r)
|