File tree Expand file tree Collapse file tree 4 files changed +33
-6
lines changed
Expand file tree Collapse file tree 4 files changed +33
-6
lines changed Original file line number Diff line number Diff line change 22
33import pytest
44
5- from fastapi import HTTPException , status
5+ from fastapi import HTTPException , Request , status
66from app .endpoints .config import config_endpoint_handler
77from configuration import AppConfig
88
@@ -15,7 +15,11 @@ def test_config_endpoint_handler_configuration_not_loaded(mocker):
1515 )
1616 mocker .patch ("app.endpoints.config.configuration" , None )
1717
18- request = None
18+ request = Request (
19+ scope = {
20+ "type" : "http" ,
21+ }
22+ )
1923 with pytest .raises (HTTPException ) as e :
2024 config_endpoint_handler (request )
2125 assert e .status_code == status .HTTP_500_INTERNAL_SERVER_ERROR
@@ -49,7 +53,11 @@ def test_config_endpoint_handler_configuration_loaded():
4953 }
5054 cfg = AppConfig ()
5155 cfg .init_from_dict (config_dict )
52- request = None
56+ request = Request (
57+ scope = {
58+ "type" : "http" ,
59+ }
60+ )
5361 response = config_endpoint_handler (request )
5462 assert response is not None
5563 assert response == cfg .configuration
Original file line number Diff line number Diff line change 11"""Unit tests for the /info REST API endpoint."""
22
3+ from fastapi import Request
4+
35from app .endpoints .info import info_endpoint_handler
46from configuration import AppConfig
57
@@ -28,7 +30,11 @@ def test_info_endpoint():
2830 }
2931 cfg = AppConfig ()
3032 cfg .init_from_dict (config_dict )
31- request = None
33+ request = Request (
34+ scope = {
35+ "type" : "http" ,
36+ }
37+ )
3238 response = info_endpoint_handler (request )
3339 assert response is not None
3440 assert response .name is not None
Original file line number Diff line number Diff line change 11"""Unit tests for the /metrics REST API endpoint."""
22
3+ from fastapi import Request
4+
35from app .endpoints .metrics import metrics_endpoint_handler
46
57
@@ -8,7 +10,12 @@ async def test_metrics_endpoint(mocker):
810 mock_setup_metrics = mocker .patch (
911 "app.endpoints.metrics.setup_model_metrics" , return_value = None
1012 )
11- response = await metrics_endpoint_handler (None )
13+ request = Request (
14+ scope = {
15+ "type" : "http" ,
16+ }
17+ )
18+ response = await metrics_endpoint_handler (request )
1219 assert response is not None
1320 assert response .status_code == 200
1421 assert "text/plain" in response .headers ["Content-Type" ]
Original file line number Diff line number Diff line change 11"""Unit tests for the / endpoint handler."""
22
3+ from fastapi import Request
4+
35from app .endpoints .root import root_endpoint_handler
46
57
68def test_root_endpoint ():
79 """Test the root endpoint handler."""
8- request = None
10+ request = Request (
11+ scope = {
12+ "type" : "http" ,
13+ }
14+ )
915 response = root_endpoint_handler (request )
1016 assert response is not None
You can’t perform that action at this time.
0 commit comments