def _addNetworkWithExc(self, netName, opts, errCode): fakeInfo = netinfo.cache.CachingNetInfo(FAKE_NETINFO) configurator = ifcfg.Ifcfg(fakeInfo) with self.assertRaises(errors.ConfigNetworkError) as cneContext: canonicalize_networks({netName: opts}) legacy_switch._add_network(netName, configurator, fakeInfo, **opts) self.assertEqual(cneContext.exception.errCode, errCode)
def _addNetworkWithExc(self, netName, opts, errCode): fakeInfo = netinfo.cache.CachingNetInfo(FAKE_NETINFO) configurator = ifcfg.Ifcfg(fakeInfo) with pytest.raises(errors.ConfigNetworkError) as cneContext: canonicalize_networks({netName: opts}) validator.validate_network_setup({netName: opts}, {}, FAKE_NETINFO) legacy_switch._add_network(netName, configurator, fakeInfo, None, **opts) assert cneContext.value.errCode == errCode