def test_init_des_iface_infos_only(self): ifaces = Ifaces( cur_iface_infos=[], des_iface_infos=self._gen_iface_infos() ) assert [ i.original_dict for i in ifaces.values() ] == self._gen_iface_infos()
def test_state_to_edit_with_changed_only(self): cur_iface_infos = self._gen_iface_infos() ifaces = Ifaces([], cur_iface_infos) for iface in ifaces.values(): iface.mark_as_changed() assert sorted([i[Interface.NAME] for i in ifaces.state_to_edit ]) == sorted([FOO1_IFACE_NAME, FOO2_IFACE_NAME])
def test_remove_unknown_interfaces(self): des_iface_infos = self._gen_iface_infos() cur_iface_info = { Interface.NAME: FOO3_IFACE_NAME, Interface.TYPE: InterfaceType.UNKNOWN, Interface.STATE: InterfaceState.UP, } ifaces = Ifaces(des_iface_infos, [cur_iface_info]) assert cur_iface_info not in ifaces.values()