diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/adapters/dcae/test_des.py | 8 | ||||
-rwxr-xr-x | test/config/osdf_config.yaml | 2 | ||||
-rw-r--r-- | test/osdf/utils/test_interfaces.py | 12 |
3 files changed, 12 insertions, 10 deletions
diff --git a/test/adapters/dcae/test_des.py b/test/adapters/dcae/test_des.py index 6daa29b..6e2520a 100644 --- a/test/adapters/dcae/test_des.py +++ b/test/adapters/dcae/test_des.py @@ -19,6 +19,7 @@ import mock from mock import patch from requests import RequestException +from requests.exceptions import HTTPError import unittest from osdf.adapters.dcae import des from osdf.adapters.dcae.des import DESException @@ -51,19 +52,20 @@ class TestDes(unittest.TestCase): response.status_code = 200 response.ok = True response.json.return_value = response_json - self.patcher_req = patch('requests.post', return_value=response) + self.patcher_req = patch('requests.request', return_value=response) self.Mock_req = self.patcher_req.start() self.assertEqual(expected, des.extract_data(service_id, data)) self.patcher_req.stop() response = mock.MagicMock() response.status_code = 404 - self.patcher_req = patch('requests.post', return_value=response) + response.raise_for_status.side_effect = HTTPError("404") + self.patcher_req = patch('requests.request', return_value=response) self.Mock_req = self.patcher_req.start() self.assertRaises(DESException, des.extract_data, service_id, data) self.patcher_req.stop() - self.patcher_req = patch('requests.post', side_effect=RequestException("error")) + self.patcher_req = patch('requests.request', side_effect=RequestException("error")) self.Mock_req = self.patcher_req.start() self.assertRaises(DESException, des.extract_data, service_id, data) self.patcher_req.stop() diff --git a/test/config/osdf_config.yaml b/test/config/osdf_config.yaml index 793de63..2b38ddd 100755 --- a/test/config/osdf_config.yaml +++ b/test/config/osdf_config.yaml @@ -72,7 +72,7 @@ aaiUrl: "https://aai.url:30233" aaiServiceInstanceUrl : "/aai/v20/nodes/service-instances/service-instance/" #DES api -desUrl: https://des.url:9000 +desUrl: http://des.url:9000 desApiPath: /datalake/v1/exposure/ desHeaders: Accept: application/json diff --git a/test/osdf/utils/test_interfaces.py b/test/osdf/utils/test_interfaces.py index cdb3d7a..8d66e16 100644 --- a/test/osdf/utils/test_interfaces.py +++ b/test/osdf/utils/test_interfaces.py @@ -16,12 +16,13 @@ # ------------------------------------------------------------------------- # import requests -import unittest - from requests.models import Response -from osdf.utils.interfaces import RestClient, get_rest_client +import unittest from unittest.mock import patch +from osdf.utils.interfaces import get_rest_client +from osdf.utils.interfaces import RestClient + m1 = Response() m1._content = b'{"msg": "OK"}' @@ -39,7 +40,7 @@ class TestOsdfUtilsInterfaces(unittest.TestCase): def test_rc_request(self, mock_good_response): rc = RestClient() rc.add_headers({}) - rc.request(req_id="testReq") + rc.request(url="http://localhost", req_id="testReq") @patch('requests.request', return_value=mock_good_response) def test_rc_request_v1(self, mock_good_response): @@ -53,7 +54,7 @@ class TestOsdfUtilsInterfaces(unittest.TestCase): def test_rc_request_v2(self, mock_bad_response): rc = RestClient() try: - rc.request() + rc.request(url="http://localhost") except requests.RequestException: return raise Exception("Allows bad requests instead of raising exception") @@ -66,4 +67,3 @@ class TestOsdfUtilsInterfaces(unittest.TestCase): if __name__ == "__main__": unittest.main() - |