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
def testValidateNetSetupRemoveParamValidation(self): networks = { 'test-network': { 'nic': 'dummy', 'remove': True, 'bridged': True } } with pytest.raises(errors.ConfigNetworkError) as cneContext: validator.validate_network_setup(networks, {}, FAKE_NETINFO) assert cneContext.value.errCode == errors.ERR_BAD_PARAMS
def testValidateNetSetupRemoveParamValidation(self, bond_mock): bond_mock.return_value.bonds.return_value = [] networks = { 'test-network': { 'nic': 'dummy', 'remove': True, 'bridged': True } } with pytest.raises(errors.ConfigNetworkError) as cneContext: validator.validate_network_setup(networks, {}, {'networks': {}}) assert cneContext.value.errCode == errors.ERR_BAD_PARAMS
def testValidateNetSetupRemoveParamValidation(self, bond_mock): bond_mock.return_value.bonds.return_value = [] networks = { 'test-network': { 'nic': 'dummy', 'remove': True, 'bridged': True } } with self.assertRaises(errors.ConfigNetworkError) as cneContext: validator.validate_network_setup(networks, {}, {}) self.assertEqual(cneContext.exception.errCode, errors.ERR_BAD_PARAMS)
def _validate_network_with_err(self, netName, opts, errCode): with pytest.raises(errors.ConfigNetworkError) as cneContext: canonicalize_networks({netName: opts}) validator.validate_network_setup({netName: opts}, {}, FAKE_NETINFO) assert cneContext.value.errCode == errCode