diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-03-01 15:20:10 +0100 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-03-02 09:31:43 +0100 |
commit | 5cb9051a0418815636a1d5df66940e168c4e0a56 (patch) | |
tree | 04e2c7a4361f36b324fb8a11ccaa448b229ba68c /functest/tests/unit/openstack | |
parent | 67363022f2139fea4049743bc00b32cf8e5f453e (diff) |
Leverage on Xtesting
It removes all the files which have moved to Xtesting.
Vnf inheritances and env management will be improved in other
changes.
It keeps the same tree thanks to a symlink to allow publishing
artifacts.
Change-Id: I551bbd3f344cdab0158a50b7b09e541576695631
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/tests/unit/openstack')
5 files changed, 50 insertions, 53 deletions
diff --git a/functest/tests/unit/openstack/rally/test_rally.py b/functest/tests/unit/openstack/rally/test_rally.py index 9cc6bf53d..989ade090 100644 --- a/functest/tests/unit/openstack/rally/test_rally.py +++ b/functest/tests/unit/openstack/rally/test_rally.py @@ -13,12 +13,11 @@ import os import unittest import mock +from snaps.openstack.os_credentials import OSCreds +from xtesting.core import testcase -from functest.core import testcase from functest.opnfv_tests.openstack.rally import rally -from snaps.openstack.os_credentials import OSCreds - class OSRallyTesting(unittest.TestCase): # pylint: disable=too-many-public-methods diff --git a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py index 1d5cc69f4..c26857e4d 100644 --- a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py +++ b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py @@ -15,13 +15,12 @@ import unittest import mock import pkg_resources +from snaps.openstack.os_credentials import OSCreds +from xtesting.core import testcase -from functest.core import testcase from functest.opnfv_tests.openstack.refstack_client.refstack_client import \ RefstackClient, RefstackClientParser -from snaps.openstack.os_credentials import OSCreds - __author__ = ("Matthew Li <matthew.lijun@huawei.com>," "Linda Wang <wangwulin@huawei.com>") diff --git a/functest/tests/unit/openstack/snaps/test_snaps.py b/functest/tests/unit/openstack/snaps/test_snaps.py index 3d9e9df07..8bbf70f4a 100644 --- a/functest/tests/unit/openstack/snaps/test_snaps.py +++ b/functest/tests/unit/openstack/snaps/test_snaps.py @@ -13,8 +13,8 @@ import unittest import mock from snaps.openstack.os_credentials import OSCreds +from xtesting.core import testcase -from functest.core.testcase import TestCase from functest.opnfv_tests.openstack.snaps import ( connection_check, api_check, health_check, smoke) @@ -41,9 +41,9 @@ class ConnectionCheckTesting(unittest.TestCase): args[0].return_value.testsRun = 100 args[0].return_value.failures = [] args[0].return_value.errors = [] - self.assertEquals(TestCase.EX_OK, self.connection_check.run()) + self.assertEquals(testcase.TestCase.EX_OK, self.connection_check.run()) self.assertEquals( - TestCase.EX_OK, self.connection_check.is_successful()) + testcase.TestCase.EX_OK, self.connection_check.is_successful()) args[0].assert_called_with(mock.ANY) args[1].assert_called_with( ext_net_name='foo', os_creds=self.os_creds, suite=mock.ANY, @@ -57,9 +57,10 @@ class ConnectionCheckTesting(unittest.TestCase): args[0].return_value.testsRun = 100 args[0].return_value.failures = ['foo'] args[0].return_value.errors = [] - self.assertEquals(TestCase.EX_OK, self.connection_check.run()) + self.assertEquals(testcase.TestCase.EX_OK, self.connection_check.run()) self.assertEquals( - TestCase.EX_TESTCASE_FAILED, self.connection_check.is_successful()) + testcase.TestCase.EX_TESTCASE_FAILED, + self.connection_check.is_successful()) args[0].assert_called_with(mock.ANY) args[1].assert_called_with( ext_net_name='foo', os_creds=self.os_creds, suite=mock.ANY, @@ -74,9 +75,9 @@ class ConnectionCheckTesting(unittest.TestCase): args[0].return_value.testsRun = 100 args[0].return_value.failures = ['foo'] args[0].return_value.errors = [] - self.assertEquals(TestCase.EX_OK, self.connection_check.run()) + self.assertEquals(testcase.TestCase.EX_OK, self.connection_check.run()) self.assertEquals( - TestCase.EX_OK, self.connection_check.is_successful()) + testcase.TestCase.EX_OK, self.connection_check.is_successful()) args[0].assert_called_with(mock.ANY) args[1].assert_called_with( ext_net_name='foo', os_creds=self.os_creds, suite=mock.ANY, @@ -105,9 +106,9 @@ class APICheckTesting(unittest.TestCase): args[0].return_value.testsRun = 100 args[0].return_value.failures = [] args[0].return_value.errors = [] - self.assertEquals(TestCase.EX_OK, self.api_check.run()) + self.assertEquals(testcase.TestCase.EX_OK, self.api_check.run()) self.assertEquals( - TestCase.EX_OK, self.api_check.is_successful()) + testcase.TestCase.EX_OK, self.api_check.is_successful()) args[0].assert_called_with(mock.ANY) args[1].assert_called_with( ext_net_name='foo', image_metadata=mock.ANY, @@ -121,9 +122,10 @@ class APICheckTesting(unittest.TestCase): args[0].return_value.testsRun = 100 args[0].return_value.failures = ['foo'] args[0].return_value.errors = [] - self.assertEquals(TestCase.EX_OK, self.api_check.run()) + self.assertEquals(testcase.TestCase.EX_OK, self.api_check.run()) self.assertEquals( - TestCase.EX_TESTCASE_FAILED, self.api_check.is_successful()) + testcase.TestCase.EX_TESTCASE_FAILED, + self.api_check.is_successful()) args[0].assert_called_with(mock.ANY) args[1].assert_called_with( ext_net_name='foo', image_metadata=mock.ANY, @@ -138,9 +140,9 @@ class APICheckTesting(unittest.TestCase): args[0].return_value.testsRun = 100 args[0].return_value.failures = ['foo'] args[0].return_value.errors = [] - self.assertEquals(TestCase.EX_OK, self.api_check.run()) + self.assertEquals(testcase.TestCase.EX_OK, self.api_check.run()) self.assertEquals( - TestCase.EX_OK, self.api_check.is_successful()) + testcase.TestCase.EX_OK, self.api_check.is_successful()) args[0].assert_called_with(mock.ANY) args[1].assert_called_with( ext_net_name='foo', image_metadata=mock.ANY, @@ -169,9 +171,9 @@ class HealthCheckTesting(unittest.TestCase): args[0].return_value.testsRun = 100 args[0].return_value.failures = [] args[0].return_value.errors = [] - self.assertEquals(TestCase.EX_OK, self.health_check.run()) + self.assertEquals(testcase.TestCase.EX_OK, self.health_check.run()) self.assertEquals( - TestCase.EX_OK, self.health_check.is_successful()) + testcase.TestCase.EX_OK, self.health_check.is_successful()) args[0].assert_called_with(mock.ANY) args[1].assert_called_with( mock.ANY, ext_net_name='foo', flavor_metadata=None, @@ -186,9 +188,10 @@ class HealthCheckTesting(unittest.TestCase): args[0].return_value.testsRun = 100 args[0].return_value.failures = ['foo'] args[0].return_value.errors = [] - self.assertEquals(TestCase.EX_OK, self.health_check.run()) + self.assertEquals(testcase.TestCase.EX_OK, self.health_check.run()) self.assertEquals( - TestCase.EX_TESTCASE_FAILED, self.health_check.is_successful()) + testcase.TestCase.EX_TESTCASE_FAILED, + self.health_check.is_successful()) args[0].assert_called_with(mock.ANY) args[1].assert_called_with( mock.ANY, ext_net_name='foo', flavor_metadata=None, @@ -204,9 +207,9 @@ class HealthCheckTesting(unittest.TestCase): args[0].return_value.testsRun = 100 args[0].return_value.failures = ['foo'] args[0].return_value.errors = [] - self.assertEquals(TestCase.EX_OK, self.health_check.run()) + self.assertEquals(testcase.TestCase.EX_OK, self.health_check.run()) self.assertEquals( - TestCase.EX_OK, self.health_check.is_successful()) + testcase.TestCase.EX_OK, self.health_check.is_successful()) args[0].assert_called_with(mock.ANY) args[1].assert_called_with( mock.ANY, ext_net_name='foo', flavor_metadata=None, @@ -236,8 +239,8 @@ class SmokeTesting(unittest.TestCase): args[0].return_value.testsRun = 100 args[0].return_value.failures = [] args[0].return_value.errors = [] - self.assertEquals(TestCase.EX_OK, self.smoke.run()) - self.assertEquals(TestCase.EX_OK, self.smoke.is_successful()) + self.assertEquals(testcase.TestCase.EX_OK, self.smoke.run()) + self.assertEquals(testcase.TestCase.EX_OK, self.smoke.is_successful()) args[0].assert_called_with(mock.ANY) args[1].assert_called_with( ext_net_name='foo', flavor_metadata=None, image_metadata=mock.ANY, @@ -252,9 +255,9 @@ class SmokeTesting(unittest.TestCase): args[0].return_value.testsRun = 100 args[0].return_value.failures = ['foo'] args[0].return_value.errors = [] - self.assertEquals(TestCase.EX_OK, self.smoke.run()) + self.assertEquals(testcase.TestCase.EX_OK, self.smoke.run()) self.assertEquals( - TestCase.EX_TESTCASE_FAILED, self.smoke.is_successful()) + testcase.TestCase.EX_TESTCASE_FAILED, self.smoke.is_successful()) args[0].assert_called_with(mock.ANY) args[1].assert_called_with( ext_net_name='foo', flavor_metadata=None, image_metadata=mock.ANY, @@ -270,9 +273,9 @@ class SmokeTesting(unittest.TestCase): args[0].return_value.testsRun = 100 args[0].return_value.failures = ['foo'] args[0].return_value.errors = [] - self.assertEquals(TestCase.EX_OK, self.smoke.run()) + self.assertEquals(testcase.TestCase.EX_OK, self.smoke.run()) self.assertEquals( - TestCase.EX_OK, self.smoke.is_successful()) + testcase.TestCase.EX_OK, self.smoke.is_successful()) args[0].assert_called_with(mock.ANY) args[1].assert_called_with( ext_net_name='foo', flavor_metadata=None, image_metadata=mock.ANY, diff --git a/functest/tests/unit/openstack/tempest/test_tempest.py b/functest/tests/unit/openstack/tempest/test_tempest.py index ba2c1c48f..8600506ad 100644 --- a/functest/tests/unit/openstack/tempest/test_tempest.py +++ b/functest/tests/unit/openstack/tempest/test_tempest.py @@ -12,13 +12,12 @@ import os import unittest import mock +from snaps.openstack.os_credentials import OSCreds +from xtesting.core import testcase -from functest.core import testcase from functest.opnfv_tests.openstack.tempest import tempest from functest.opnfv_tests.openstack.tempest import conf_utils -from snaps.openstack.os_credentials import OSCreds - class OSTempestTesting(unittest.TestCase): @@ -72,7 +71,8 @@ class OSTempestTesting(unittest.TestCase): self.tempestcommon.generate_test_list('test_verifier_repo_dir') self.assertTrue(mock_copyfile.called) - def _test_gen_tl_mode_default(self, mode): + @mock.patch('functest.utils.functest_utils.execute_command') + def _test_gen_tl_mode_default(self, mode, mock_exec=None): self.tempestcommon.mode = mode if self.tempestcommon.mode == 'smoke': testr_mode = r"'tempest\.(api|scenario).*\[.*\bsmoke\b.*\]'" @@ -82,14 +82,12 @@ class OSTempestTesting(unittest.TestCase): testr_mode = 'tempest.api.' + self.tempestcommon.mode conf_utils.TEMPEST_RAW_LIST = 'raw_list' verifier_repo_dir = 'test_verifier_repo_dir' - with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' - 'ft_utils.execute_command') as mock_exec: - cmd = ("cd {0};" - "testr list-tests {1} > {2};" - "cd -;".format(verifier_repo_dir, testr_mode, - conf_utils.TEMPEST_RAW_LIST)) - self.tempestcommon.generate_test_list('test_verifier_repo_dir') - mock_exec.assert_any_call(cmd) + cmd = ("cd {0};" + "testr list-tests {1} > {2};" + "cd -;".format(verifier_repo_dir, testr_mode, + conf_utils.TEMPEST_RAW_LIST)) + self.tempestcommon.generate_test_list('test_verifier_repo_dir') + mock_exec.assert_any_call(cmd) def test_gen_tl_smoke_mode(self): self._test_gen_tl_mode_default('smoke') @@ -221,9 +219,9 @@ class OSTempestTesting(unittest.TestCase): def test_run_apply_blacklist_ko(self): with mock.patch.object(self.tempestcommon, 'generate_test_list'), \ - mock.patch.object(self.tempestcommon, - 'apply_tempest_blacklist', - side_effect=Exception()): + mock.patch.object( + self.tempestcommon, 'apply_tempest_blacklist', + side_effect=Exception()): self._test_run(testcase.TestCase.EX_RUN_ERROR) def test_run_verifier_tests_ko(self): diff --git a/functest/tests/unit/openstack/vping/test_vping.py b/functest/tests/unit/openstack/vping/test_vping.py index 91cf22599..85e5ab9e8 100644 --- a/functest/tests/unit/openstack/vping/test_vping.py +++ b/functest/tests/unit/openstack/vping/test_vping.py @@ -14,23 +14,20 @@ import logging import unittest import mock - from snaps.config.keypair import KeypairConfig from snaps.config.network import NetworkConfig, PortConfig, SubnetConfig from snaps.config.router import RouterConfig from snaps.config.security_group import SecurityGroupConfig from snaps.config.vm_inst import VmInstanceConfig - from snaps.openstack.create_image import OpenStackImage from snaps.openstack.create_instance import OpenStackVmInstance from snaps.openstack.create_keypairs import OpenStackKeypair from snaps.openstack.create_network import OpenStackNetwork from snaps.openstack.create_router import OpenStackRouter from snaps.openstack.create_security_group import OpenStackSecurityGroup - from snaps.openstack.os_credentials import OSCreds +from xtesting.core import testcase -from functest.core.testcase import TestCase from functest.opnfv_tests.openstack.vping import vping_userdata, vping_ssh @@ -82,7 +79,8 @@ class VPingUserdataTesting(unittest.TestCase): mock.patch('snaps.openstack.create_instance.' 'OpenStackVmInstance.get_console_output', return_value='vPing OK'): - self.assertEquals(TestCase.EX_OK, self.vping_userdata.run()) + self.assertEquals( + testcase.TestCase.EX_OK, self.vping_userdata.run()) class VPingSSHTesting(unittest.TestCase): @@ -117,7 +115,7 @@ class VPingSSHTesting(unittest.TestCase): @mock.patch('functest.opnfv_tests.openstack.vping.vping_ssh.' 'VPingSSH._transfer_ping_script', return_value=True) @mock.patch('functest.opnfv_tests.openstack.vping.vping_ssh.' - 'VPingSSH._do_vping_ssh', return_value=TestCase.EX_OK) + 'VPingSSH._do_vping_ssh', return_value=testcase.TestCase.EX_OK) @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.' 'get_ext_net_name', return_value='foo') def test_vping_ssh(self, *args): @@ -166,7 +164,7 @@ class VPingSSHTesting(unittest.TestCase): mock.patch('snaps.openstack.create_instance.' 'OpenStackVmInstance.' 'ssh_client', return_value=ssh_client): - self.assertEquals(TestCase.EX_OK, self.vping_ssh.run()) + self.assertEquals(testcase.TestCase.EX_OK, self.vping_ssh.run()) if __name__ == "__main__": |