Replace assert_raises with try: except:

Replace assert_raises with try: except: in
  negative_admin_bonding_in_lacp_mode.negative_admin_bonding_in_lacp_mode
Reason: real exception is hidden and not enough info about test fail
Fixed PASS scenario from previous changeset
Closes-bug: #1580640

Change-Id: Ie58c3abe14df801a7a6b30403c107e973ecd5f67
(cherry picked from commit 3edafbf434)
This commit is contained in:
Alexey Stepanov 2016-05-11 18:08:42 +03:00
parent 9aef49ef7d
commit d93fa9d384

View File

@ -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"])