From d93fa9d3843bb9688e77b7769e0ea589dc824827 Mon Sep 17 00:00:00 2001 From: Alexey Stepanov Date: Wed, 11 May 2016 18:08:42 +0300 Subject: [PATCH] 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 3edafbf4340539daa2c6e52766d977f58170db73) --- fuelweb_test/tests/test_bonding.py | 38 ++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/fuelweb_test/tests/test_bonding.py b/fuelweb_test/tests/test_bonding.py index 38b9cb2d6..328637739 100644 --- a/fuelweb_test/tests/test_bonding.py +++ b/fuelweb_test/tests/test_bonding.py @@ -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"])