Skip to content

Commit ffe9c25

Browse files
authored
removed public reviews (v1) endpoint (#293)
1 parent f139279 commit ffe9c25

File tree

2 files changed

+5
-80
lines changed

2 files changed

+5
-80
lines changed

data_hub_api/main.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22

33
from fastapi import FastAPI
44
from fastapi.responses import HTMLResponse
5-
from data_hub_api.config import ADDITIONAL_MANUSCRIPT_IDS
6-
from data_hub_api.docmaps.v1.api_router import create_docmaps_router as create_docmaps_router_v1
75
from data_hub_api.docmaps.v2.api_router import create_docmaps_router
86
from data_hub_api.kotahi_docmaps.v1.api_router import (
97
create_docmaps_router as create_docmaps_router_for_kotahi
108
)
119

1210
from data_hub_api.utils.cache import InMemorySingleObjectCache
13-
from data_hub_api.docmaps.v1.provider import DocmapsProviderV1
1411
from data_hub_api.docmaps.v2.provider import DocmapsProvider
1512
from data_hub_api.kotahi_docmaps.v1.provider import DocmapsProvider as KotahiDocmapsProvider
1613

@@ -21,19 +18,9 @@
2118
def create_app():
2219
app = FastAPI()
2320

24-
docmaps_v1_max_age_in_seconds = 60 * 60 # 1 hour
2521
docmaps_v2_max_age_in_seconds = 10 * 60 # 10 minutes
2622
kotahi_docmaps_max_age_in_seconds = 60 * 60 # 1 hour
2723

28-
enhanced_preprints_docmaps_provider_v1 = DocmapsProviderV1(
29-
only_include_reviewed_preprint_type=True,
30-
only_include_evaluated_preprints=False,
31-
additionally_include_manuscript_ids=ADDITIONAL_MANUSCRIPT_IDS,
32-
query_results_cache=InMemorySingleObjectCache(
33-
max_age_in_seconds=docmaps_v2_max_age_in_seconds
34-
)
35-
)
36-
3724
enhanced_preprints_docmaps_provider = DocmapsProvider(
3825
query_results_cache=InMemorySingleObjectCache(
3926
max_age_in_seconds=docmaps_v2_max_age_in_seconds
@@ -46,27 +33,12 @@ def create_app():
4633
)
4734
)
4835

49-
public_reviews_docmaps_provider = DocmapsProviderV1(
50-
only_include_reviewed_preprint_type=False,
51-
only_include_evaluated_preprints=True,
52-
query_results_cache=InMemorySingleObjectCache(
53-
max_age_in_seconds=docmaps_v1_max_age_in_seconds
54-
)
55-
)
56-
5736
@app.get("/")
5837
def get_root():
5938
with open("data_hub_api/index.html", "r", encoding='utf-8') as file:
6039
html_content = file.read()
6140
return HTMLResponse(content=html_content, status_code=200)
6241

63-
app.include_router(
64-
create_docmaps_router_v1(
65-
enhanced_preprints_docmaps_provider_v1
66-
),
67-
prefix='/enhanced-preprints/docmaps'
68-
)
69-
7042
app.include_router(
7143
create_docmaps_router(
7244
enhanced_preprints_docmaps_provider
@@ -81,11 +53,4 @@ def get_root():
8153
prefix='/kotahi/docmaps'
8254
)
8355

84-
app.include_router(
85-
create_docmaps_router_v1(
86-
public_reviews_docmaps_provider
87-
),
88-
prefix='/public-reviews/docmaps'
89-
)
90-
9156
return app

tests/unit_tests/main_test.py

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
from unittest.mock import ANY, call, patch, MagicMock
1+
from unittest.mock import patch, MagicMock
22
from typing import Iterable, Sequence
33

44
import pytest
55

66
from fastapi.testclient import TestClient
77

88
from data_hub_api import main as main_module
9-
from data_hub_api.config import ADDITIONAL_MANUSCRIPT_IDS
109
from data_hub_api.main import create_app
1110

1211

@@ -16,7 +15,7 @@
1615

1716
@pytest.fixture(name='enhanced_preprints_docmaps_provider_class_mock', autouse=True)
1817
def _enhanced_preprints_docmaps_provider_class_mock() -> Iterable[MagicMock]:
19-
with patch.object(main_module, 'DocmapsProviderV1') as mock:
18+
with patch.object(main_module, 'DocmapsProvider') as mock:
2019
yield mock
2120

2221

@@ -36,13 +35,6 @@ def _enhanced_preprints_docmaps_provider_mock(
3635
return docmaps_provider_mock_list[0]
3736

3837

39-
@pytest.fixture(name='public_reviews_docmaps_provider_mock')
40-
def _public_reviews_docmaps_provider_mock(
41-
docmaps_provider_mock_list: Sequence[MagicMock]
42-
) -> MagicMock:
43-
return docmaps_provider_mock_list[1]
44-
45-
4638
def test_read_main():
4739
client = TestClient(create_app())
4840
response = client.get("/")
@@ -57,7 +49,7 @@ def test_should_return_json_with_docmaps_list_from_enhanced_preprint_provider(
5749
docmaps_index = [{'docmaps': [{'id': 'docmap_1'}, {'id': 'docmap_2'}]}]
5850
enhanced_preprints_docmaps_provider_mock.get_docmaps_index.return_value = docmaps_index
5951
client = TestClient(create_app())
60-
response = client.get('/enhanced-preprints/docmaps/v1/index')
52+
response = client.get('/enhanced-preprints/docmaps/v2/index')
6153
assert response.json() == docmaps_index
6254

6355
def test_should_return_not_available_message_for_invalid_manuscript_id_by_elife(
@@ -67,7 +59,7 @@ def test_should_return_not_available_message_for_invalid_manuscript_id_by_elife(
6759
enhanced_preprints_docmaps_provider_mock.get_docmaps_by_manuscript_id.return_value = []
6860
client = TestClient(create_app())
6961
response = client.get(
70-
'/enhanced-preprints/docmaps/v1/by-publisher/elife/get-by-manuscript-id',
62+
'/enhanced-preprints/docmaps/v2/by-publisher/elife/get-by-manuscript-id',
7163
params={'manuscript_id': MANUSCRIPT_ID}
7264
)
7365
assert response.status_code == 404
@@ -85,43 +77,11 @@ def test_should_docmap_from_epp_provider_for_individual_by_publisher_manuscript_
8577
)
8678
client = TestClient(create_app())
8779
response = client.get(
88-
'/enhanced-preprints/docmaps/v1/by-publisher/elife/get-by-manuscript-id',
80+
'/enhanced-preprints/docmaps/v2/by-publisher/elife/get-by-manuscript-id',
8981
params={'manuscript_id': MANUSCRIPT_ID}
9082
)
9183
enhanced_preprints_docmaps_provider_mock.get_docmaps_by_manuscript_id.assert_called_with(
9284
MANUSCRIPT_ID
9385
)
9486
assert response.status_code == 200
9587
assert response.json() == article_docmap_list[0]
96-
97-
def test_should_return_json_with_docmaps_list_from_public_review_provider(
98-
self,
99-
public_reviews_docmaps_provider_mock: MagicMock
100-
):
101-
docmaps_index = [{'docmaps': [{'id': 'docmap_1'}, {'id': 'docmap_2'}]}]
102-
public_reviews_docmaps_provider_mock.get_docmaps_index.return_value = docmaps_index
103-
client = TestClient(create_app())
104-
response = client.get('/public-reviews/docmaps/v1/index')
105-
assert response.json() == docmaps_index
106-
107-
def test_should_pass_correct_parameters_to_provider_class(
108-
self,
109-
enhanced_preprints_docmaps_provider_class_mock: MagicMock
110-
):
111-
create_app()
112-
enhanced_preprints_docmaps_provider_class_mock.assert_has_calls(
113-
[
114-
call(
115-
only_include_reviewed_preprint_type=True,
116-
only_include_evaluated_preprints=False,
117-
additionally_include_manuscript_ids=ADDITIONAL_MANUSCRIPT_IDS,
118-
query_results_cache=ANY
119-
),
120-
call(
121-
only_include_reviewed_preprint_type=False,
122-
only_include_evaluated_preprints=True,
123-
query_results_cache=ANY
124-
)
125-
],
126-
any_order=False
127-
)

0 commit comments

Comments
 (0)