File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
tests/unit_tests/docmaps/v2 Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,12 @@ def get_enhanced_preprints_docmaps_by_manuscript_id_by_publisher_elife(manuscrip
3434
3535 @router .get ("/v2/evaluation/get-by-evaluation-id" , response_class = HTMLResponse )
3636 def get_evaluation_text_by_evaluation_id (evaluation_id : str ):
37- return docmaps_provider .get_evaluation_content_by_id (evaluation_id )
37+ evaluation_content = docmaps_provider .get_evaluation_content_by_id (evaluation_id )
38+ if not evaluation_content :
39+ raise HTTPException (
40+ status_code = 404 ,
41+ detail = f"No evaluation content available for evaluation_id: { evaluation_id } "
42+ )
43+ return evaluation_content
3844
3945 return router
Original file line number Diff line number Diff line change @@ -88,5 +88,5 @@ def iter_docmaps_index_json_stream(self):
8888 raise
8989 LOGGER .info ('Finished streaming docmaps index as JSON.' )
9090
91- def get_evaluation_content_by_id (self , evaluation_id : str ) -> str :
91+ def get_evaluation_content_by_id (self , evaluation_id : str ) -> Optional [ str ] :
9292 return 'dummy evaluation content for evaluation_id: ' + evaluation_id
Original file line number Diff line number Diff line change @@ -72,6 +72,18 @@ def test_should_return_docmap_from_provider_by_publisher_for_individual_manuscri
7272 assert response .status_code == 200
7373 assert response .json () == article_docmap_list [0 ]
7474
75+ def test_should_return_not_found_status_code_for_invalid_evaluation_id (
76+ self ,
77+ docmaps_provider_mock : MagicMock
78+ ):
79+ docmaps_provider_mock .get_evaluation_content_by_id .return_value = None
80+ client = create_test_client (docmaps_provider_mock )
81+ response = client .get (
82+ '/v2/evaluation/get-by-evaluation-id' ,
83+ params = {'evaluation_id' : 'non_existent_evaluation_id_1' }
84+ )
85+ assert response .status_code == 404
86+
7587 def test_should_return_evaluation_content_from_provider (
7688 self ,
7789 docmaps_provider_mock : MagicMock
You can’t perform that action at this time.
0 commit comments