summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-12-27 16:18:51 +0100
committerCédric Ollivier <cedric.ollivier@orange.com>2018-12-27 18:38:40 +0100
commit1a8158ca410222afd938ffa729bdd3879f6032da (patch)
treef24d1f8290f02cfe9d92cbaa26bad1a000bff3ad
parent53b3da37fcb717ec6c24c434874967f1b503d328 (diff)
Update Xtesting to 0.61
It now generates html reports for unit tests (snaps). Change-Id: Ica8fab2b383723957c1068c5accbcab9568002ac Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com> (cherry picked from commit 98ee1837b939f32c2c3bc17787065d0bf0a22c3f)
-rw-r--r--functest/tests/unit/openstack/snaps/test_snaps.py163
-rw-r--r--upper-constraints.txt2
2 files changed, 101 insertions, 64 deletions
diff --git a/functest/tests/unit/openstack/snaps/test_snaps.py b/functest/tests/unit/openstack/snaps/test_snaps.py
index 14bc38596..db8e3e04a 100644
--- a/functest/tests/unit/openstack/snaps/test_snaps.py
+++ b/functest/tests/unit/openstack/snaps/test_snaps.py
@@ -40,36 +40,45 @@ class APICheckTesting(unittest.TestCase):
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('unittest.TextTestRunner.run',
- return_value=mock.MagicMock(name='unittest.TextTestResult'))
+ @mock.patch('subunit.run.SubunitTestRunner.run')
def test_run_success(self, *args):
- args[0].return_value.testsRun = 100
- args[0].return_value.failures = []
- args[0].return_value.errors = []
- self.assertEquals(testcase.TestCase.EX_OK, self.api_check.run())
- self.assertEquals(
+ 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('unittest.TextTestRunner.run',
- return_value=mock.MagicMock(name='unittest.TextTestResult'))
+ @mock.patch('subunit.run.SubunitTestRunner.run')
def test_run_1_of_100_ko(self, *args):
- args[0].return_value.testsRun = 100
- args[0].return_value.failures = ['foo']
- args[0].return_value.errors = []
- self.assertEquals(testcase.TestCase.EX_OK, self.api_check.run())
- self.assertEquals(
+ 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)
@@ -77,19 +86,23 @@ class APICheckTesting(unittest.TestCase):
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('unittest.TextTestRunner.run',
- return_value=mock.MagicMock(name='unittest.TextTestResult'))
+ @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.testsRun = 100
- args[0].return_value.failures = ['foo']
- args[0].return_value.errors = []
- self.assertEquals(testcase.TestCase.EX_OK, self.api_check.run())
- self.assertEquals(
+ 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(
@@ -117,16 +130,20 @@ class HealthCheckTesting(unittest.TestCase):
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('unittest.TextTestRunner.run',
- return_value=mock.MagicMock(name='unittest.TextTestResult'))
+ @mock.patch('subunit.run.SubunitTestRunner.run')
def test_run_success(self, *args):
- args[0].return_value.testsRun = 100
- args[0].return_value.failures = []
- args[0].return_value.errors = []
- self.assertEquals(testcase.TestCase.EX_OK, self.health_check.run())
- self.assertEquals(
+ 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(
@@ -134,16 +151,20 @@ class HealthCheckTesting(unittest.TestCase):
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('unittest.TextTestRunner.run',
- return_value=mock.MagicMock(name='unittest.TextTestResult'))
+ @mock.patch('subunit.run.SubunitTestRunner.run')
def test_run_1_of_100_ko(self, *args):
- args[0].return_value.testsRun = 100
- args[0].return_value.failures = ['foo']
- args[0].return_value.errors = []
- self.assertEquals(testcase.TestCase.EX_OK, self.health_check.run())
- self.assertEquals(
+ 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)
@@ -152,17 +173,21 @@ class HealthCheckTesting(unittest.TestCase):
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('unittest.TextTestRunner.run',
- return_value=mock.MagicMock(name='unittest.TextTestResult'))
+ @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.testsRun = 100
- args[0].return_value.failures = ['foo']
- args[0].return_value.errors = []
- self.assertEquals(testcase.TestCase.EX_OK, self.health_check.run())
- self.assertEquals(
+ 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(
@@ -191,16 +216,20 @@ class SmokeTesting(unittest.TestCase):
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('unittest.TextTestRunner.run',
- return_value=mock.MagicMock(name='unittest.TextTestResult'))
+ @mock.patch('subunit.run.SubunitTestRunner.run')
def test_run_success(self, *args):
- args[0].return_value.testsRun = 100
- args[0].return_value.failures = []
- args[0].return_value.errors = []
- self.assertEquals(testcase.TestCase.EX_OK, self.smoke.run())
- self.assertEquals(testcase.TestCase.EX_OK, self.smoke.is_successful())
+ 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,
@@ -208,16 +237,20 @@ class SmokeTesting(unittest.TestCase):
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('unittest.TextTestRunner.run',
- return_value=mock.MagicMock(name='unittest.TextTestResult'))
+ @mock.patch('subunit.run.SubunitTestRunner.run')
def test_run_1_of_100_ko(self, *args):
- args[0].return_value.testsRun = 100
- args[0].return_value.failures = ['foo']
- args[0].return_value.errors = []
- self.assertEquals(testcase.TestCase.EX_OK, self.smoke.run())
- self.assertEquals(
+ 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(
@@ -226,17 +259,21 @@ class SmokeTesting(unittest.TestCase):
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('unittest.TextTestRunner.run',
- return_value=mock.MagicMock(name='unittest.TextTestResult'))
+ @mock.patch('subunit.run.SubunitTestRunner.run')
def test_run_1_of_100_ko_criteria(self, *args):
self.smoke.criteria = 90
- args[0].return_value.testsRun = 100
- args[0].return_value.failures = ['foo']
- args[0].return_value.errors = []
- self.assertEquals(testcase.TestCase.EX_OK, self.smoke.run())
- self.assertEquals(
+ 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(
diff --git a/upper-constraints.txt b/upper-constraints.txt
index b5ad2b4e0..5c7991e8a 100644
--- a/upper-constraints.txt
+++ b/upper-constraints.txt
@@ -13,6 +13,6 @@ robotframework-httplibrary===0.4.2
robotframework-requests===0.4.7
robotframework-sshlibrary===2.1.3;python_version=='2.7'
ansible===2.3.2.0
-xtesting===0.60.0
+xtesting===0.61.0
networking-bgpvpn===8.0.0
networking-sfc===6.0.0