Merge "Replace assert_raises with try: except:" into stable/mitaka
This commit is contained in:
commit
68388969db
@ -15,12 +15,12 @@
|
||||
from copy import deepcopy
|
||||
|
||||
from proboscis.asserts import assert_equal
|
||||
from proboscis.asserts import assert_raises
|
||||
from proboscis import test
|
||||
# pylint: disable=import-error
|
||||
from six.moves.urllib.error import HTTPError
|
||||
# pylint: enable=import-error
|
||||
|
||||
from fuelweb_test import logger
|
||||
from fuelweb_test.helpers.decorators import log_snapshot_after_test
|
||||
from fuelweb_test.settings import DEPLOYMENT_MODE
|
||||
from fuelweb_test.settings import NEUTRON_SEGMENT
|
||||
@ -209,12 +209,36 @@ class BondingHAOneController(BondingTest):
|
||||
nailgun_nodes = self.fuel_web.client.list_cluster_nodes(cluster_id)
|
||||
invalid_bond_conf = deepcopy(self.BOND_CONFIG)
|
||||
invalid_bond_conf[1]['mode'] = '802.3ad'
|
||||
assert_raises(
|
||||
HTTPError,
|
||||
self.fuel_web.update_node_networks,
|
||||
nailgun_nodes[0]['id'],
|
||||
interfaces_dict=deepcopy(self.INTERFACES),
|
||||
raw_data=invalid_bond_conf)
|
||||
invalid_bond_conf[1]['bond_properties']['mode'] = '802.3ad'
|
||||
interfaces_dict = deepcopy(self.INTERFACES)
|
||||
|
||||
exp_code = 400
|
||||
try:
|
||||
self.fuel_web.update_node_networks(
|
||||
nailgun_nodes[0]['id'],
|
||||
interfaces_dict=interfaces_dict,
|
||||
raw_data=invalid_bond_conf)
|
||||
except HTTPError as exc:
|
||||
if exc.code != exp_code:
|
||||
logger.error(
|
||||
'Raised: {exc!s},\n'
|
||||
'Expected: {exp} with code={code}'.format(
|
||||
exc=exc, exp=HTTPError.__class__, code=exp_code))
|
||||
raise
|
||||
|
||||
logger.info('Test PASS: expected exception raised: '
|
||||
'{!s}'.format(exc))
|
||||
return
|
||||
except BaseException as exc:
|
||||
logger.error(
|
||||
'Raised: {exc!s},\n'
|
||||
'Expected: {exp} with code={code}'.format(
|
||||
exc=exc, exp=HTTPError.__class__, code=exp_code))
|
||||
raise
|
||||
raise AssertionError(
|
||||
'Not raised any exception, while expected '
|
||||
'{exp} with code={code}'.format(
|
||||
exp=HTTPError.__class__, code=exp_code))
|
||||
|
||||
|
||||
@test(groups=["bonding_neutron", "bonding_ha", "bonding"])
|
||||
|
Loading…
Reference in New Issue
Block a user