From 650c9e5853ea57b985df1e9d97288a7d879a2e4f Mon Sep 17 00:00:00 2001 From: Scott Bahling Date: Thu, 13 Feb 2020 11:43:10 +0100 Subject: Implement general exception handling We trap the low level OBS api calls via a callback and check for success. If error returned, parse the OBS error response and raise an exception. --- test/test_api.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test') diff --git a/test/test_api.py b/test/test_api.py index 09b2806..f6ccdf4 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -204,6 +204,15 @@ def locked_package_meta(): """ +@pytest.fixture +def error_status(): + return """ + This is the summary +
Here are the details
+
+ """ + + def test_callback(requests_mock): """ Test that api callback works and returns a reference to @@ -218,6 +227,15 @@ def test_callback(requests_mock): assert api.lastapi is api.source +def test_call_status_on_error(requests_mock, error_status): + requests_mock.get(rmock.ANY, text=error_status, status_code=404) + with pytest.raises(Exception): + api.ls() + assert api.call_status.code == "Error" + assert api.call_status.summary == "This is the summary" + assert api.call_status.details == "Here are the details" + + def test_get_project_meta(requests_mock): matcher = prj_meta_re text = '' -- cgit v1.2.3