aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2019-03-11 13:55:40 +0100
committerCédric Ollivier <cedric.ollivier@orange.com>2019-03-12 19:00:47 +0100
commite44841210c53290207db9b958c66cb8019910cb7 (patch)
tree5b2693803938d0c1b3314c4d4f84d9ee17adf0f7 /functest/tests
parentd217430315c5ac571c0006c1178ff6ac50bd3d3a (diff)
Remove Snaps-based testcases
Snaps hasn't been synchronized for a while regarding requirements. We do remove it due to the inactivity. All test result tabs will be updated in a second change. Change-Id: I834afd902829ed3883b0e88e92aa806ec43d6fcf Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/tests')
-rw-r--r--functest/tests/unit/ci/__init__.py0
-rw-r--r--functest/tests/unit/ci/test_check_deployment.py286
-rw-r--r--functest/tests/unit/openstack/snaps/__init__.py0
-rw-r--r--functest/tests/unit/openstack/snaps/test_snaps.py288
-rw-r--r--functest/tests/unit/vnf/epc/test_juju_epc.py1
5 files changed, 0 insertions, 575 deletions
diff --git a/functest/tests/unit/ci/__init__.py b/functest/tests/unit/ci/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/functest/tests/unit/ci/__init__.py
+++ /dev/null
diff --git a/functest/tests/unit/ci/test_check_deployment.py b/functest/tests/unit/ci/test_check_deployment.py
deleted file mode 100644
index aeeca5871..000000000
--- a/functest/tests/unit/ci/test_check_deployment.py
+++ /dev/null
@@ -1,286 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2017 Ericsson and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-
-# pylint: disable=missing-docstring
-
-import socket
-import unittest
-
-import logging
-import mock
-
-from functest.ci import check_deployment
-
-__author__ = "Jose Lausuch <jose.lausuch@ericsson.com>"
-
-
-class CheckDeploymentTesting(unittest.TestCase):
- """The super class which testing classes could inherit."""
- # pylint: disable=missing-docstring,too-many-public-methods
-
- logging.disable(logging.CRITICAL)
-
- def setUp(self):
- self.client_test = mock.Mock()
- self.deployment = check_deployment.CheckDeployment()
- self.service_test = 'compute'
- self.rc_file = self.deployment.rc_file
- self.endpoint_test = 'http://192.168.0.6:5000/v3'
- creds_attr = {'auth_url': self.endpoint_test,
- 'proxy_settings': ''}
- proxy_attr = {'host': '192.168.0.1', 'port': '5000'}
- proxy_settings = mock.Mock()
- proxy_settings.configure_mock(**proxy_attr)
- self.os_creds = mock.Mock()
- self.os_creds.configure_mock(**creds_attr)
- self.os_creds.proxy_settings = proxy_settings
- self.deployment.os_creds = self.os_creds
-
- @mock.patch('socket.socket.connect', side_effect=TypeError)
- def test_verify_connectivity_ko1(self, *args):
- self.assertFalse(check_deployment.verify_connectivity("127.0.0.1"))
- args[0].assert_called_once_with((None, 80))
-
- @mock.patch('socket.socket.connect', side_effect=socket.error)
- def test_verify_connectivity_ko2(self, *args):
- self.assertFalse(
- check_deployment.verify_connectivity("http://127.0.0.1"))
- args[0].assert_called_once_with(("127.0.0.1", 80))
-
- @mock.patch('socket.socket.connect', side_effect=socket.error)
- def test_verify_connectivity_ko3(self, *args):
- self.assertFalse(
- check_deployment.verify_connectivity("https://127.0.0.1"))
- args[0].assert_called_once_with(("127.0.0.1", 443))
-
- @mock.patch('socket.socket.connect')
- def test_verify_connectivity(self, *args):
- self.assertTrue(
- check_deployment.verify_connectivity("https://127.0.0.1"))
- args[0].assert_called_once_with(("127.0.0.1", 443))
-
- @mock.patch('snaps.openstack.utils.keystone_utils.keystone_session',
- return_value=mock.Mock(
- get_token=mock.Mock(side_effect=Exception)))
- def test_get_auth_token_ko(self, *args):
- with self.assertRaises(Exception):
- check_deployment.get_auth_token(self.os_creds)
- args[0].assert_called_once_with(self.os_creds)
-
- @mock.patch('snaps.openstack.utils.keystone_utils.keystone_session',
- return_value=mock.Mock(
- get_token=mock.Mock(return_value="foo")))
- def test_get_auth_token(self, *args):
- self.assertEqual(check_deployment.get_auth_token(self.os_creds), "foo")
- args[0].assert_called_once_with(self.os_creds)
-
- @mock.patch('six.moves.builtins.open',
- mock.mock_open(read_data='OS_AUTH_URL'))
- @mock.patch('functest.ci.check_deployment.os.path.isfile', returns=True)
- def test_check_rc(self, *args):
- self.deployment.check_rc()
- args[0].assert_called_once_with(self.rc_file)
-
- @mock.patch('functest.ci.check_deployment.os.path.isfile',
- return_value=False)
- def test_check_rc_missing_file(self, *args):
- with self.assertRaises(Exception) as context:
- self.deployment.check_rc()
- args[0].assert_called_once_with(self.rc_file)
- msg = 'RC file {} does not exist!'.format(self.rc_file)
- self.assertTrue(msg in str(context.exception))
-
- @mock.patch('six.moves.builtins.open',
- mock.mock_open(read_data='test'))
- @mock.patch('functest.ci.check_deployment.os.path.isfile',
- return_value=True)
- def test_check_rc_missing_os_auth(self, *args):
- with self.assertRaises(Exception) as context:
- self.deployment.check_rc()
- args[0].assert_called_once_with(self.rc_file)
- msg = 'OS_AUTH_URL not defined in {}.'.format(self.rc_file)
- self.assertTrue(msg in str(context.exception))
-
- @mock.patch('functest.ci.check_deployment.get_auth_token',
- return_value='gAAAAABaOhXGS')
- @mock.patch('functest.ci.check_deployment.verify_connectivity',
- return_value=True)
- def test_check_auth_endpoint(self, *args):
- self.deployment.check_auth_endpoint()
- args[0].assert_called_once_with(self.endpoint_test)
- args[1].assert_called_once_with(mock.ANY)
-
- @mock.patch('functest.ci.check_deployment.verify_connectivity',
- return_value=False)
- def test_check_auth_endpoint_ko(self, *args):
- with self.assertRaises(Exception) as context:
- self.deployment.check_auth_endpoint()
- msg = "OS_AUTH_URL {} is not reachable.".format(self.os_creds.auth_url)
- args[0].assert_called_once_with(self.os_creds.auth_url)
- self.assertTrue(msg in str(context.exception))
-
- @mock.patch('functest.ci.check_deployment.verify_connectivity',
- return_value=True)
- @mock.patch('functest.ci.check_deployment.keystone_utils.get_endpoint')
- def test_check_public_endpoint(self, *args):
- args[0].return_value = self.endpoint_test
- self.deployment.check_public_endpoint()
- args[0].assert_called_once_with(
- mock.ANY, 'identity', interface='public')
- args[1].assert_called_once_with(self.endpoint_test)
-
- @mock.patch('functest.ci.check_deployment.verify_connectivity',
- return_value=False)
- @mock.patch('functest.ci.check_deployment.keystone_utils.get_endpoint')
- def test_check_public_endpoint_ko(self, *args):
- args[0].return_value = self.endpoint_test
- with self.assertRaises(Exception) as context:
- self.deployment.check_public_endpoint()
- args[0].assert_called_once_with(
- mock.ANY, 'identity', interface='public')
- args[1].assert_called_once_with(self.endpoint_test)
- msg = "Public endpoint {} is not reachable.".format(self.endpoint_test)
- self.assertTrue(msg in str(context.exception))
-
- @mock.patch('functest.ci.check_deployment.verify_connectivity',
- return_value=True)
- @mock.patch('functest.ci.check_deployment.keystone_utils.get_endpoint')
- def test_check_service_endpoint(self, *args):
- self.deployment.check_service_endpoint(self.service_test)
- args[0].assert_called_once_with(
- mock.ANY, self.service_test, interface='public')
- args[1].assert_called_once_with(args[0].return_value)
-
- @mock.patch('functest.ci.check_deployment.verify_connectivity',
- return_value=False)
- @mock.patch('functest.ci.check_deployment.keystone_utils.get_endpoint')
- def test_check_service_endpoint_ko(self, *args):
- args[0].return_value = self.endpoint_test
- with self.assertRaises(Exception) as context:
- self.deployment.check_service_endpoint(self.service_test)
- msg = "{} endpoint {} is not reachable.".format(
- self.service_test, self.endpoint_test)
- self.assertTrue(msg in str(context.exception))
- args[0].assert_called_once_with(
- mock.ANY, self.service_test, interface='public')
- args[1].assert_called_once_with(args[0].return_value)
-
- @mock.patch('functest.ci.check_deployment.nova_utils.nova_client')
- def test_check_nova(self, mock_method):
- self.deployment.check_nova()
- mock_method.assert_called_once_with(mock.ANY)
-
- @mock.patch('functest.ci.check_deployment.nova_utils.nova_client',
- return_value=mock.Mock(
- servers=mock.Mock(list=mock.Mock(side_effect=Exception))))
- def test_check_nova_fail(self, mock_method):
- with self.assertRaises(Exception):
- self.deployment.check_nova()
- mock_method.assert_called_once_with(mock.ANY)
-
- @mock.patch('functest.ci.check_deployment.neutron_utils.neutron_client')
- def test_check_neutron(self, mock_method):
- self.deployment.check_neutron()
- mock_method.assert_called_once_with(mock.ANY)
-
- @mock.patch('functest.ci.check_deployment.neutron_utils.neutron_client',
- return_value=mock.Mock(
- list_networks=mock.Mock(side_effect=Exception)))
- def test_check_neutron_fail(self, mock_method):
- with self.assertRaises(Exception):
- self.deployment.check_neutron()
- mock_method.assert_called_once_with(mock.ANY)
-
- @mock.patch('functest.ci.check_deployment.glance_utils.glance_client')
- def test_check_glance(self, mock_method):
- self.deployment.check_glance()
- mock_method.assert_called_once_with(mock.ANY)
-
- @mock.patch('functest.ci.check_deployment.glance_utils.glance_client',
- return_value=mock.Mock(
- images=mock.Mock(list=mock.Mock(side_effect=Exception))))
- def test_check_glance_fail(self, mock_method):
- with self.assertRaises(Exception):
- self.deployment.check_glance()
- mock_method.assert_called_once_with(mock.ANY)
-
- @mock.patch('functest.ci.check_deployment.LOGGER.info')
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
- 'get_ext_net_name', return_value='ext-net')
- def test_check_extnet(self, *args):
- self.deployment.check_ext_net()
- args[0].assert_called_once_with(mock.ANY)
- args[1].assert_called_once_with(
- "External network found: %s", "ext-net")
-
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
- 'get_ext_net_name', return_value='')
- def test_check_extnet_none(self, mock_getext):
- with self.assertRaises(Exception) as context:
- self.deployment.check_ext_net()
- self.assertTrue(mock_getext.called)
- msg = 'ERROR: No external networks in the deployment.'
- self.assertTrue(msg in str(context.exception))
-
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_rc',
- side_effect=Exception)
- def test_check_all_exc1(self, *args):
- with self.assertRaises(Exception):
- self.deployment.check_all()
- args[0].assert_called_once_with()
-
- @mock.patch('snaps.openstack.tests.openstack_tests.get_credentials',
- side_effect=Exception)
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_rc')
- def test_check_all_exc2(self, *args):
- with self.assertRaises(Exception):
- self.deployment.check_all()
- args[0].assert_called_once_with()
- args[1].assert_called_once_with(
- os_env_file=self.rc_file, proxy_settings_str=None,
- ssh_proxy_cmd=None)
-
- @mock.patch('snaps.openstack.tests.openstack_tests.get_credentials',
- return_value=None)
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_rc')
- def test_check_all_exc3(self, *args):
- with self.assertRaises(Exception):
- self.deployment.check_all()
- args[0].assert_called_once_with()
- args[1].assert_called_once_with(
- os_env_file=self.rc_file, proxy_settings_str=None,
- ssh_proxy_cmd=None)
-
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_ext_net')
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_glance')
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_neutron')
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_nova')
- @mock.patch(
- 'functest.ci.check_deployment.CheckDeployment.check_service_endpoint')
- @mock.patch(
- 'functest.ci.check_deployment.CheckDeployment.check_public_endpoint')
- @mock.patch(
- 'functest.ci.check_deployment.CheckDeployment.check_auth_endpoint')
- @mock.patch('snaps.openstack.tests.openstack_tests.get_credentials')
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_rc')
- def test_check_all(self, *args):
- self.assertEqual(self.deployment.check_all(), 0)
- for i in [0, 2, 3, 5, 6, 7, 8]:
- args[i].assert_called_once_with()
- args[1].assert_called_once_with(
- os_env_file=self.rc_file, proxy_settings_str=None,
- ssh_proxy_cmd=None)
- calls = [mock.call('compute'), mock.call('network'),
- mock.call('image')]
- args[4].assert_has_calls(calls)
-
-
-if __name__ == "__main__":
- logging.disable(logging.CRITICAL)
- unittest.main(verbosity=2)
diff --git a/functest/tests/unit/openstack/snaps/__init__.py b/functest/tests/unit/openstack/snaps/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/functest/tests/unit/openstack/snaps/__init__.py
+++ /dev/null
diff --git a/functest/tests/unit/openstack/snaps/test_snaps.py b/functest/tests/unit/openstack/snaps/test_snaps.py
deleted file mode 100644
index db8e3e04a..000000000
--- a/functest/tests/unit/openstack/snaps/test_snaps.py
+++ /dev/null
@@ -1,288 +0,0 @@
-# Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-
-# pylint: disable=missing-docstring
-
-import logging
-import unittest
-
-import mock
-from snaps.openstack.os_credentials import OSCreds
-from xtesting.core import testcase
-
-from functest.opnfv_tests.openstack.snaps import api_check
-from functest.opnfv_tests.openstack.snaps import health_check
-from functest.opnfv_tests.openstack.snaps import smoke
-
-
-class APICheckTesting(unittest.TestCase):
- """
- Ensures the ApiCheck class can run in Functest. This test does not
- actually connect with an OpenStack pod.
- """
-
- def setUp(self):
- self.os_creds = OSCreds(
- username='user', password='pass',
- auth_url='http://foo.com:5000/v3', project_name='bar')
- with mock.patch('os_client_config.get_config') as mock_get_config, \
- mock.patch('shade.OpenStackCloud') as mock_shade, \
- mock.patch('functest.core.tenantnetwork.NewProject') \
- as mock_new_project:
- self.api_check = api_check.ApiCheck(
- os_creds=self.os_creds, ext_net_name='foo')
- mock_get_config.assert_called()
- mock_shade.assert_called()
- mock_new_project.assert_called()
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('unittest.TestLoader')
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_client_tests')
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_api_tests')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_success(self, *args):
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=[]))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.api_check.run())
- self.assertEqual(
- 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,
- os_creds=self.os_creds, suite=mock.ANY, use_keystone=True)
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_client_tests')
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_api_tests')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_1_of_100_ko(self, *args):
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=['foo']))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.api_check.run())
- self.assertEqual(
- 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,
- os_creds=self.os_creds, suite=mock.ANY, use_keystone=True)
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_client_tests')
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_api_tests')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_1_of_100_ko_criteria(self, *args):
- self.api_check.criteria = 90
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=['foo']))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.api_check.run())
- self.assertEqual(
- 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,
- os_creds=self.os_creds, suite=mock.ANY, use_keystone=True)
-
-
-class HealthCheckTesting(unittest.TestCase):
- """
- Ensures the HealthCheck class can run in Functest. This test does not
- actually connect with an OpenStack pod.
- """
-
- def setUp(self):
- self.os_creds = OSCreds(
- username='user', password='pass',
- auth_url='http://foo.com:5000/v3', project_name='bar')
- with mock.patch('os_client_config.get_config') as mock_get_config, \
- mock.patch('shade.OpenStackCloud') as mock_shade, \
- mock.patch('functest.core.tenantnetwork.NewProject') \
- as mock_new_project:
- self.health_check = health_check.HealthCheck(
- os_creds=self.os_creds, ext_net_name='foo')
- mock_get_config.assert_called()
- mock_shade.assert_called()
- mock_new_project.assert_called()
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('snaps.openstack.tests.os_source_file_test.'
- 'OSIntegrationTestCase.parameterize')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_success(self, *args):
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=[]))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.health_check.run())
- self.assertEqual(
- 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=mock.ANY,
- image_metadata=mock.ANY, netconf_override=None,
- os_creds=self.os_creds, use_keystone=True)
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('snaps.openstack.tests.os_source_file_test.'
- 'OSIntegrationTestCase.parameterize')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_1_of_100_ko(self, *args):
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=['foo']))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.health_check.run())
- self.assertEqual(
- 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=mock.ANY,
- image_metadata=mock.ANY, netconf_override=None,
- os_creds=self.os_creds, use_keystone=True)
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('snaps.openstack.tests.os_source_file_test.'
- 'OSIntegrationTestCase.parameterize')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_1_of_100_ko_criteria(self, *args):
- self.health_check.criteria = 90
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=['foo']))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.health_check.run())
- self.assertEqual(
- 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=mock.ANY,
- image_metadata=mock.ANY, netconf_override=None,
- os_creds=self.os_creds, use_keystone=True)
-
-
-class SmokeTesting(unittest.TestCase):
- """
- Ensures the SnapsSmoke class can run in Functest. This test does not
- actually connect with an OpenStack pod.
- """
-
- def setUp(self):
- self.os_creds = OSCreds(
- username='user', password='pass',
- auth_url='http://foo.com:5000/v3', project_name='bar')
- with mock.patch('os_client_config.get_config') as mock_get_config, \
- mock.patch('shade.OpenStackCloud') as mock_shade, \
- mock.patch('functest.core.tenantnetwork.NewProject') \
- as mock_new_project:
- self.smoke = smoke.SnapsSmoke(
- os_creds=self.os_creds, ext_net_name='foo')
- mock_get_config.assert_called()
- mock_shade.assert_called()
- mock_new_project.assert_called()
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_integration_tests')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_success(self, *args):
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=[]))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.smoke.run())
- self.assertEqual(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=mock.ANY,
- image_metadata=mock.ANY, netconf_override=None,
- os_creds=self.os_creds, suite=mock.ANY, use_floating_ips=True,
- use_keystone=True)
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_integration_tests')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_1_of_100_ko(self, *args):
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=['foo']))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.smoke.run())
- self.assertEqual(
- 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=mock.ANY,
- image_metadata=mock.ANY, netconf_override=mock.ANY,
- os_creds=self.os_creds, suite=mock.ANY, use_floating_ips=True,
- use_keystone=True)
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_integration_tests')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_1_of_100_ko_criteria(self, *args):
- self.smoke.criteria = 90
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=['foo']))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.smoke.run())
- self.assertEqual(
- 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=mock.ANY,
- image_metadata=mock.ANY, netconf_override=None,
- os_creds=self.os_creds, suite=mock.ANY, use_floating_ips=True,
- use_keystone=True)
-
-
-if __name__ == "__main__":
- logging.disable(logging.CRITICAL)
- unittest.main(verbosity=2)
diff --git a/functest/tests/unit/vnf/epc/test_juju_epc.py b/functest/tests/unit/vnf/epc/test_juju_epc.py
index 6b4137069..a72c61586 100644
--- a/functest/tests/unit/vnf/epc/test_juju_epc.py
+++ b/functest/tests/unit/vnf/epc/test_juju_epc.py
@@ -62,7 +62,6 @@ class JujuEpcTesting(unittest.TestCase):
'test_vnf': {}}
@unittest.skip("It must be fixed. Please see JIRA FUNCTEST-915")
- @mock.patch('snaps.openstack.create_image.OpenStackImage.create')
@mock.patch('os.system')
def test_prepare_default(self, *args):
""" Unittest for Prepare testcase """