"""Test request methods.""" import httpx from owsclient.test import OwsClientMock from reserves_schedule 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(service, path, **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': 1} 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(service, path, body, **options) assert result.status_code == 200 assert result.json() == {'message': 'OK'} assert route.call_count == 1