def test_do_not_merge_down_state_from_current(self): iface_info = gen_foo_iface_info() cur_iface_info = gen_foo_iface_info() iface_info.pop(Interface.STATE) cur_iface_info[Interface.STATE] = InterfaceState.DOWN iface = BaseIface(iface_info) cur_iface = BaseIface(cur_iface_info) iface.merge(cur_iface) assert iface.is_up
def test_merge(self): des_info = gen_foo_iface_info() des_info.update({ "list_a": [], "dict_b": { "item_a": 1, "dict_c": { "item_b": 2 } } }) cur_info = gen_foo_iface_info() cur_info.update({ "state": "up", "list_a": ["a", "b", "c"], "dict_b": { "item_a1": 11, "dict_c": { "item_b": 3, "item_d": 4 }, }, }) ori_cur_info = deepcopy(cur_info) ori_des_info = deepcopy(des_info) des_iface = BaseIface(des_info) cur_iface = BaseIface(cur_info) des_iface.merge(cur_iface) expected_info = gen_foo_iface_info() expected_info.update({ "list_a": [], "dict_b": { "item_a": 1, "item_a1": 11, "dict_c": { "item_b": 2, "item_d": 4 }, }, }) assert cur_info == ori_cur_info assert des_info == ori_des_info assert cur_iface.to_dict() == ori_cur_info assert des_iface.to_dict() == expected_info