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_valid(tomcat, mock_text):
mock_text.return_value = 'OK - some message\nthe result'
r = tomcat.vm_info()
assert r.status_code == tm.status_codes.ok
assert r.status_message == 'some message'
assert r.result == 'the result'
def test_connect_auth(self, tomcat_manager_server):
tomcat = tm.TomcatManager()
r = tomcat.connect(
tomcat_manager_server.url,
tomcat_manager_server.user,
tomcat_manager_server.password
)
assert isinstance(r, tm.models.TomcatManagerResponse)
assert r.status_code == tm.status_codes.ok
assert tomcat.is_connected
assert r.result == ''
assert r.status_message == ''
r.raise_for_status()
def raise_for_status(self):
"""
Raise exceptions for server errors.
First call `requests.Response.raise_for_status()` which
raises exceptions if a 4xx or 5xx response is received from the
server.
If that doesn't raise anything, then raise a `TomcatError`
if there is not an ``OK`` response from the first line of text back
from the Tomcat Manager web app.
"""
self.response.raise_for_status()
if self.status_code != tm.status_codes.ok:
raise TomcatError(self.status_message)