diff --git a/oaipmh/requests/data_queries.py b/oaipmh/requests/data_queries.py
index 0d7071c..c553a2f 100644
--- a/oaipmh/requests/data_queries.py
+++ b/oaipmh/requests/data_queries.py
@@ -1,12 +1,12 @@
from typing import Dict
+from oaipmh.serializers.output_formats import Response
-from oaipmh.serializers.output_formats import InteriorData
-def get_record(params: Dict[str, str]) -> InteriorData:
- return
+def get_record(params: Dict[str, str]) -> Response:
+ return "b", 200, {}
-def list_records(params: Dict[str, str]) -> InteriorData:
- return
+def list_records(params: Dict[str, str]) -> Response:
+ return "b", 200, {}
-def list_identifiers(params: Dict[str, str]) -> InteriorData:
- return
+def list_identifiers(params: Dict[str, str]) -> Response:
+ return "b", 200, {}
diff --git a/oaipmh/requests/info_queries.py b/oaipmh/requests/info_queries.py
index c6e8a99..9dece80 100644
--- a/oaipmh/requests/info_queries.py
+++ b/oaipmh/requests/info_queries.py
@@ -1,11 +1,11 @@
from typing import Dict
-from oaipmh.serializers.output_formats import InteriorData
+from oaipmh.serializers.output_formats import Response
-def identify(params: Dict[str, str]) -> InteriorData:
- return
+def identify(params: Dict[str, str]) -> Response:
+ return "b", 200, {}
-def list_metadata_formats(params: Dict[str, str]) -> InteriorData:
- return
+def list_metadata_formats(params: Dict[str, str]) -> Response:
+ return "b", 200, {}
-def list_sets(params: Dict[str, str]) -> InteriorData:
- return
+def list_sets(params: Dict[str, str]) -> Response:
+ return "b", 200, {}
diff --git a/oaipmh/requests/routes.py b/oaipmh/requests/routes.py
index ac75de7..6dfef39 100644
--- a/oaipmh/requests/routes.py
+++ b/oaipmh/requests/routes.py
@@ -1,8 +1,9 @@
from typing import Dict
from datetime import datetime, timezone
-from flask import Blueprint, request, Response, render_template
+from flask import Blueprint, request, render_template
from oaipmh.requests.verb_sorter import verb_sorter
+from oaipmh.serializers.output_formats import Response
blueprint = Blueprint('general', __name__)
@@ -10,18 +11,13 @@
@blueprint.route("/oai", methods=['GET', 'POST'])
def oai() -> Response:
- #TODO what happens if duplicate params
+ #TODO duplicate params dont create errors, technically not to spec
params: Dict[str, str] = request.args.to_dict() if request.method == 'GET' else request.form.to_dict()
- result=verb_sorter(params)
- response_xml=render_template("base.xml",
- response_date=datetime.now(timezone.utc),
- request_info="request info", #TODO
- interior_xml="interior data" #TODO
- )
- headers={"Content-Type":"application/xml"}
+ response, code, headers=verb_sorter(params)
+ headers["Content-Type"]="application/xml"
- return response_xml, 200, headers
+ return response, code, headers
@blueprint.route('/favicon.ico')
def favicon():
diff --git a/oaipmh/requests/verb_sorter.py b/oaipmh/requests/verb_sorter.py
index d49e7cb..41eb9d5 100644
--- a/oaipmh/requests/verb_sorter.py
+++ b/oaipmh/requests/verb_sorter.py
@@ -1,11 +1,12 @@
from typing import Dict
+
from oaipmh.requests.info_queries import identify, list_metadata_formats, list_sets
from oaipmh.requests.data_queries import get_record, list_identifiers, list_records
-from oaipmh.serializers.output_formats import InteriorData
+from oaipmh.serializers.output_formats import Response
from oaipmh.data.oai_errors import OAIBadVerb
-def verb_sorter(params: Dict[str, str]) -> InteriorData:
+def verb_sorter(params: Dict[str, str]) -> Response:
"""
sorts OAI queries to the appropriate handler based on their verb statement
this defines what the client is asking for as per the OAI standard
diff --git a/oaipmh/serializers/output_formats.py b/oaipmh/serializers/output_formats.py
index c73df8a..7a37bf2 100644
--- a/oaipmh/serializers/output_formats.py
+++ b/oaipmh/serializers/output_formats.py
@@ -1,3 +1,3 @@
+from typing import Tuple, Dict, Any
-class InteriorData: #TODO placeholder return type
- value=""
\ No newline at end of file
+Response = Tuple[Dict[str, Any], int, Dict[str, Any]]
\ No newline at end of file
diff --git a/tests/test_verb_sorting.py b/tests/test_verb_sorting.py
index ca713b4..856670c 100644
--- a/tests/test_verb_sorting.py
+++ b/tests/test_verb_sorting.py
@@ -3,12 +3,12 @@
def test_get_record(test_client):
params = {"verb": "GetRecord", "identifier": "oai:example.org:record123"}
- with patch('oaipmh.requests.verb_sorter.get_record') as mock_get_record:
+ with patch('oaipmh.requests.verb_sorter.get_record', return_value=("working", 200, {})) as mock_get_record:
response = test_client.get("/oai", query_string=params)
assert response.status_code == 200
mock_get_record.assert_called_once_with(params)
- with patch('oaipmh.requests.verb_sorter.get_record') as mock_get_record:
+ with patch('oaipmh.requests.verb_sorter.get_record', return_value=("working", 200, {})) as mock_get_record:
response = test_client.post("/oai", data=params)
assert response.status_code == 200
mock_get_record.assert_called_once_with(params)
@@ -16,12 +16,12 @@ def test_get_record(test_client):
def test_list_records(test_client):
params = {"verb": "ListRecords", "metadataPrefix": "oai_dc"}
- with patch('oaipmh.requests.verb_sorter.list_records') as mock_list_records:
+ with patch('oaipmh.requests.verb_sorter.list_records', return_value=("working", 200, {})) as mock_list_records:
response = test_client.get("/oai", query_string=params)
assert response.status_code == 200
mock_list_records.assert_called_once_with(params)
- with patch('oaipmh.requests.verb_sorter.list_records') as mock_list_records:
+ with patch('oaipmh.requests.verb_sorter.list_records', return_value=("working", 200, {})) as mock_list_records:
response = test_client.post("/oai", data=params)
assert response.status_code == 200
mock_list_records.assert_called_once_with(params)
@@ -29,12 +29,12 @@ def test_list_records(test_client):
def test_list_identifiers(test_client):
params = {"verb": "ListIdentifiers", "metadataPrefix": "oai_dc"}
- with patch('oaipmh.requests.verb_sorter.list_identifiers') as mock_list_identifiers:
+ with patch('oaipmh.requests.verb_sorter.list_identifiers', return_value=("working", 200, {})) as mock_list_identifiers:
response = test_client.get("/oai", query_string=params)
assert response.status_code == 200
mock_list_identifiers.assert_called_once_with(params)
- with patch('oaipmh.requests.verb_sorter.list_identifiers') as mock_list_identifiers:
+ with patch('oaipmh.requests.verb_sorter.list_identifiers', return_value=("working", 200, {})) as mock_list_identifiers:
response = test_client.post("/oai", data=params)
assert response.status_code == 200
mock_list_identifiers.assert_called_once_with(params)
@@ -42,12 +42,12 @@ def test_list_identifiers(test_client):
def test_identify(test_client):
params = {"verb": "Identify"}
- with patch('oaipmh.requests.verb_sorter.identify') as mock_identify:
+ with patch('oaipmh.requests.verb_sorter.identify', return_value=("working", 200, {})) as mock_identify:
response = test_client.get("/oai", query_string=params)
assert response.status_code == 200
mock_identify.assert_called_once_with(params)
- with patch('oaipmh.requests.verb_sorter.identify') as mock_identify:
+ with patch('oaipmh.requests.verb_sorter.identify', return_value=("working", 200, {})) as mock_identify:
response = test_client.post("/oai", data=params)
assert response.status_code == 200
mock_identify.assert_called_once_with(params)
@@ -55,12 +55,12 @@ def test_identify(test_client):
def test_list_metadata_formats(test_client):
params = {"verb": "ListMetadataFormats"}
- with patch('oaipmh.requests.verb_sorter.list_metadata_formats') as mock_list_metadata_formats:
+ with patch('oaipmh.requests.verb_sorter.list_metadata_formats', return_value=("working", 200, {})) as mock_list_metadata_formats:
response = test_client.get("/oai", query_string=params)
assert response.status_code == 200
mock_list_metadata_formats.assert_called_once_with(params)
- with patch('oaipmh.requests.verb_sorter.list_metadata_formats') as mock_list_metadata_formats:
+ with patch('oaipmh.requests.verb_sorter.list_metadata_formats', return_value=("working", 200, {})) as mock_list_metadata_formats:
response = test_client.post("/oai", data=params)
assert response.status_code == 200
mock_list_metadata_formats.assert_called_once_with(params)
@@ -68,12 +68,12 @@ def test_list_metadata_formats(test_client):
def test_list_sets(test_client):
params = {"verb": "ListSets"}
- with patch('oaipmh.requests.verb_sorter.list_sets') as mock_list_sets:
+ with patch('oaipmh.requests.verb_sorter.list_sets', return_value=("working", 200, {})) as mock_list_sets:
response = test_client.get("/oai", query_string=params)
assert response.status_code == 200
mock_list_sets.assert_called_once_with(params)
- with patch('oaipmh.requests.verb_sorter.list_sets') as mock_list_sets:
+ with patch('oaipmh.requests.verb_sorter.list_sets', return_value=("working", 200, {})) as mock_list_sets:
response = test_client.post("/oai", data=params)
assert response.status_code == 200
mock_list_sets.assert_called_once_with(params)