diff options
author | 2017-05-30 15:02:06 +0000 | |
---|---|---|
committer | 2017-05-30 15:02:06 +0000 | |
commit | a28e2b40877f022f6cc8bbc3ad9b586ef3dd126c (patch) | |
tree | 015109b1867976702a2e90b050d00af0174f2b73 /functest/tests/unit/core | |
parent | 8628e8f2bb97f4528767710ec8fdec5ea3643738 (diff) | |
parent | 49a7e57f112d855b0609721b6082b15a94417380 (diff) |
Merge "Define create_snapshot() and clean() in TestCase"
Diffstat (limited to 'functest/tests/unit/core')
-rw-r--r-- | functest/tests/unit/core/test_testcase.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/functest/tests/unit/core/test_testcase.py b/functest/tests/unit/core/test_testcase.py index ef0983cc..0a6f0c9f 100644 --- a/functest/tests/unit/core/test_testcase.py +++ b/functest/tests/unit/core/test_testcase.py @@ -221,6 +221,55 @@ class TestCaseTesting(unittest.TestCase): self.assertIn(duration, message) self.assertIn('FAIL', message) + def test_create_snapshot(self): + self.assertEqual(self.test.create_snapshot(), + testcase.TestCase.EX_OK) + + def test_clean(self): + self.assertEqual(self.test.clean(), None) + + +class OSGCTestCaseTesting(unittest.TestCase): + """The class testing OSGCTestCase.""" + # pylint: disable=missing-docstring + + def setUp(self): + self.test = testcase.OSGCTestCase() + + @mock.patch('functest.utils.openstack_snapshot.main', + side_effect=Exception) + def test_create_snapshot_exc(self, mock_method=None): + self.assertEqual(self.test.create_snapshot(), + testcase.TestCase.EX_RUN_ERROR) + mock_method.assert_called_once_with() + + @mock.patch('functest.utils.openstack_snapshot.main', return_value=-1) + def test_create_snapshot_ko(self, mock_method=None): + self.assertEqual(self.test.create_snapshot(), + testcase.TestCase.EX_RUN_ERROR) + mock_method.assert_called_once_with() + + @mock.patch('functest.utils.openstack_snapshot.main', return_value=0) + def test_create_snapshot_env(self, mock_method=None): + self.assertEqual(self.test.create_snapshot(), + testcase.TestCase.EX_OK) + mock_method.assert_called_once_with() + + @mock.patch('functest.utils.openstack_clean.main', side_effect=Exception) + def test_clean_exc(self, mock_method=None): + self.assertEqual(self.test.clean(), None) + mock_method.assert_called_once_with() + + @mock.patch('functest.utils.openstack_clean.main', return_value=-1) + def test_clean_ko(self, mock_method=None): + self.assertEqual(self.test.clean(), None) + mock_method.assert_called_once_with() + + @mock.patch('functest.utils.openstack_clean.main', return_value=0) + def test_clean(self, mock_method=None): + self.assertEqual(self.test.clean(), None) + mock_method.assert_called_once_with() + if __name__ == "__main__": logging.disable(logging.CRITICAL) |