"""Unit testcases for request methods.""" import httpx from owsclient.test import OwsClientMock from reserves_release import requests def test_get(ows_client_mock: OwsClientMock): """Test GET method.""" path = '/object/object_id' service = 'ows-service' options = {'headers': {'foo': 'bar'}} route = ows_client_mock.get( service, path, **options) route.mock( return_value=httpx.Response(200, json={'message': 'OK'}) ) result = requests.get(path=path, service=service, **options) assert result.status_code == 200 assert result.json() == {'message': 'OK'} assert route.call_count == 1 def test_post(ows_client_mock: OwsClientMock): """Test POST method.""" body = {'target_id': 666} path = '/object/object_id' service = 'ows-service' options = {'headers': {'foo': 'bar'}} route = ows_client_mock.post( service_name=service, path=path, json=body, **options ) route.mock( return_value=httpx.Response(200, json={'message': 'OK'}) ) result = requests.post(path=path, service=service, body=body, **options) assert result.status_code == 200 assert result.json() == {'message': 'OK'} assert route.call_count == 1