How to use _get_my_exception method in tempest

Best Python code snippet using tempest_python

test_decorators.py

Source:test_decorators.py Github

copy

Full Screen

...113 def test_idempotent_id_not_valid_uuid(self):114 _id = '42'115 self.assertRaises(ValueError, self._test_helper, _id)116class TestRelatedBugDecorator(base.TestCase):117 def _get_my_exception(self):118 class MyException(Exception):119 def __init__(self, status_code):120 self.status_code = status_code121 return MyException122 def test_relatedbug_when_no_exception(self):123 f = mock.Mock()124 sentinel = object()125 @decorators.related_bug(bug="1234", status_code=500)126 def test_foo(self):127 f(self)128 test_foo(sentinel)129 f.assert_called_once_with(sentinel)130 def test_relatedbug_when_exception_with_launchpad_bug_type(self):131 """Validate related_bug decorator with bug_type == 'launchpad'"""132 MyException = self._get_my_exception()133 def f(self):134 raise MyException(status_code=500)135 @decorators.related_bug(bug="1234", status_code=500)136 def test_foo(self):137 f(self)138 with mock.patch.object(decorators.LOG, 'error') as m_error:139 self.assertRaises(MyException, test_foo, object())140 m_error.assert_called_once_with(141 mock.ANY, '1234', 'https://launchpad.net/bugs/1234')142 def test_relatedbug_when_exception_with_storyboard_bug_type(self):143 """Validate related_bug decorator with bug_type == 'storyboard'"""144 MyException = self._get_my_exception()145 def f(self):146 raise MyException(status_code=500)147 @decorators.related_bug(bug="1234", status_code=500,148 bug_type='storyboard')149 def test_foo(self):150 f(self)151 with mock.patch.object(decorators.LOG, 'error') as m_error:152 self.assertRaises(MyException, test_foo, object())153 m_error.assert_called_once_with(154 mock.ANY, '1234', 'https://storyboard.openstack.org/#!/story/1234')155 def test_relatedbug_when_exception_invalid_bug_type(self):156 """Check related_bug decorator raises exc when bug_type is not valid"""157 MyException = self._get_my_exception()158 def f(self):159 raise MyException(status_code=500)160 @decorators.related_bug(bug="1234", status_code=500,161 bug_type=mock.sentinel.invalid)162 def test_foo(self):163 f(self)164 with mock.patch.object(decorators.LOG, 'error'):165 self.assertRaises(lib_exc.InvalidParam, test_foo, object())166 def test_relatedbug_when_exception_invalid_bug_number(self):167 """Check related_bug decorator raises exc when bug_number != digit"""168 MyException = self._get_my_exception()169 def f(self):170 raise MyException(status_code=500)171 @decorators.related_bug(bug="not a digit", status_code=500,172 bug_type='launchpad')173 def test_foo(self):174 f(self)175 with mock.patch.object(decorators.LOG, 'error'):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful