diff options
author | Ghanshyam Mann <gmann@ghanshyammann.com> | 2022-04-05 17:38:00 -0500 |
---|---|---|
committer | Ghanshyam <gmann@ghanshyammann.com> | 2022-04-05 23:41:14 +0000 |
commit | fc1791f8589cb8dba9d8d9ef7856be17b2bc77f3 (patch) | |
tree | 034f0b3ccd9559c3227abac0e54abbd3f4f67920 /tempest_lib/tests/test_decorators.py | |
parent | 023426894a4f72d906ed6f79c55ed7152a732b44 (diff) | |
download | tempest-lib-fc1791f8589cb8dba9d8d9ef7856be17b2bc77f3.tar.gz |
As of the 1.0.0 release tempest-lib as a separate
repository and project is deprecated. We moved all the
code to tempest.lib temepst version 10.
Hoping everyone is moved to tempest.lib now, We can retire
the tempest-lib. We discussed the same in PTG and agreed to
proceed on retirement
- https://etherpad.opendev.org/p/qa-zed-ptg
Needed-By: https://review.opendev.org/c/openstack/governance/+/836704
Change-Id: I37ceb96e084f569ea59e4849ca8770742ce17846
Diffstat (limited to 'tempest_lib/tests/test_decorators.py')
-rw-r--r-- | tempest_lib/tests/test_decorators.py | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/tempest_lib/tests/test_decorators.py b/tempest_lib/tests/test_decorators.py deleted file mode 100644 index 252e009..0000000 --- a/tempest_lib/tests/test_decorators.py +++ /dev/null @@ -1,126 +0,0 @@ -# Copyright 2013 IBM Corp -# Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import uuid - -import testtools - -from tempest_lib import base as test -from tempest_lib import decorators -from tempest_lib.tests import base - - -class TestSkipBecauseDecorator(base.TestCase): - def _test_skip_because_helper(self, expected_to_skip=True, - **decorator_args): - class TestFoo(test.BaseTestCase): - _interface = 'json' - - @decorators.skip_because(**decorator_args) - def test_bar(self): - return 0 - - t = TestFoo('test_bar') - if expected_to_skip: - self.assertRaises(testtools.TestCase.skipException, t.test_bar) - else: - # assert that test_bar returned 0 - self.assertEqual(TestFoo('test_bar').test_bar(), 0) - - def test_skip_because_bug(self): - self._test_skip_because_helper(bug='12345') - - def test_skip_because_bug_and_condition_true(self): - self._test_skip_because_helper(bug='12348', condition=True) - - def test_skip_because_bug_and_condition_false(self): - self._test_skip_because_helper(expected_to_skip=False, - bug='12349', condition=False) - - def test_skip_because_bug_without_bug_never_skips(self): - """Never skip without a bug parameter.""" - self._test_skip_because_helper(expected_to_skip=False, - condition=True) - self._test_skip_because_helper(expected_to_skip=False) - - def test_skip_because_invalid_bug_number(self): - """Raise ValueError if with an invalid bug number""" - self.assertRaises(ValueError, self._test_skip_because_helper, - bug='critical_bug') - - -class TestIdempotentIdDecorator(base.TestCase): - def _test_helper(self, _id, **decorator_args): - @decorators.idempotent_id(_id) - def foo(): - """Docstring""" - pass - - return foo - - def _test_helper_without_doc(self, _id, **decorator_args): - @decorators.idempotent_id(_id) - def foo(): - pass - - return foo - - def test_positive(self): - _id = str(uuid.uuid4()) - foo = self._test_helper(_id) - self.assertIn('id-%s' % _id, getattr(foo, '__testtools_attrs')) - self.assertTrue(foo.__doc__.startswith('Test idempotent id: %s' % _id)) - - def test_positive_without_doc(self): - _id = str(uuid.uuid4()) - foo = self._test_helper_without_doc(_id) - self.assertTrue(foo.__doc__.startswith('Test idempotent id: %s' % _id)) - - def test_idempotent_id_not_str(self): - _id = 42 - self.assertRaises(TypeError, self._test_helper, _id) - - def test_idempotent_id_not_valid_uuid(self): - _id = '42' - self.assertRaises(ValueError, self._test_helper, _id) - - -class TestSkipUnlessAttrDecorator(base.TestCase): - def _test_skip_unless_attr(self, attr, expected_to_skip=True): - class TestFoo(test.BaseTestCase): - expected_attr = not expected_to_skip - - @decorators.skip_unless_attr(attr) - def test_foo(self): - pass - - t = TestFoo('test_foo') - if expected_to_skip: - self.assertRaises(testtools.TestCase.skipException, - t.test_foo()) - else: - try: - t.test_foo() - except Exception: - raise testtools.TestCase.failureException() - - def test_skip_attr_does_not_exist(self): - self._test_skip_unless_attr('unexpected_attr') - - def test_skip_attr_false(self): - self._test_skip_unless_attr('expected_attr') - - def test_no_skip_for_attr_exist_and_true(self): - self._test_skip_unless_attr('expected_attr', expected_to_skip=False) |