Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_http_response_fail(tomcat, mock_text):
mock_text.return_value = 'FAIL - some message'
r = tomcat.vm_info()
assert r.status_code == tm.status_codes.fail
assert r.status_message == 'some message'
assert r.result is None
def test_status_xml_fail(self, tomcat):
with mock.patch('requests.models.Response.status_code', create=True,
new_callable=mock.PropertyMock) as mock_status:
# chose a status value that won't raise an exception, but
# that isn't 200, OK
mock_status.return_value = 204 # No Content
r = tomcat.status_xml()
self.failure_assertions(r)
assert r.status_code == tm.status_codes.fail
def failure_assertions(self, r):
"""
Assertions for every command that should fail.
"""
assert r.status_code == tm.status_codes.fail
with pytest.raises(tm.TomcatError):
r.raise_for_status()