def test_apply_v2_renames_skips_without_setname_or_mac( self, config_attr: str ): networking = LinuxNetworking() netcfg = yaml.load(getattr(self, config_attr)) with mock.patch.object( networking, "_rename_interfaces" ) as m_rename_interfaces: networking.apply_network_config_names(netcfg) m_rename_interfaces.assert_called_with([])
def test_apply_renames( self, m_device_driver, m_device_devid, config_attr: str, ): networking = LinuxNetworking() m_device_driver.return_value = "virtio_net" m_device_devid.return_value = "0x15d8" netcfg = yaml.load(getattr(self, config_attr)) with mock.patch.object( networking, "_rename_interfaces" ) as m_rename_interfaces: networking.apply_network_config_names(netcfg) assert ( mock.call( [["52:54:00:12:34:00", "interface0", "virtio_net", "0x15d8"]] ) == m_rename_interfaces.call_args_list[-1] )
def test_apply_v2_renames_raises_runtime_error_on_unknown_version(self): networking = LinuxNetworking() with pytest.raises(RuntimeError): networking.apply_network_config_names(yaml.load("version: 3"))