33from fastapi import HTTPException
44from sqlalchemy .orm import Session
55
6+ from app .api .constants import API_BASE
67from app .features .machine .api import create_machine , get_machine , list_machines
78from app .features .machine .models import Machine
89from app .features .machine .schemas import MachineCreate
@@ -19,7 +20,7 @@ def test_function_succeeds_with_valid_payload(self, db: Session):
1920 "notes" : "Test machine" ,
2021 }
2122
22- machine_create = MachineCreate (** payload )
23+ machine_create = MachineCreate (** payload ) # type: ignore[arg-type]
2324 machine = create_machine (machine_create , db )
2425
2526 for key in payload :
@@ -35,7 +36,7 @@ def test_endpoint_succeeds_with_valid_payload(self, client):
3536 "notes" : "Another test machine" ,
3637 }
3738
38- res = client .post ("/api /machines" , json = payload )
39+ res = client .post (f" { API_BASE } /machines" , json = payload )
3940
4041 assert res .status_code == 201
4142 data = res .json ()
@@ -66,7 +67,7 @@ def test_function_raises_error_for_duplicate_name_(self, db: Session):
6667 }
6768
6869 try :
69- machine_create = MachineCreate (** payload )
70+ machine_create = MachineCreate (** payload ) # type: ignore[arg-type]
7071 create_machine (machine_create , db )
7172 except HTTPException as e :
7273 assert str (e ) == "400: Machine with this name already exists"
@@ -93,7 +94,7 @@ def test_endpoint_raises_400_for_duplicate_name(self, client, db: Session):
9394 "notes" : "Duplicate machine" ,
9495 }
9596
96- res = client .post ("/api /machines" , json = payload )
97+ res = client .post (f" { API_BASE } /machines" , json = payload )
9798 assert res .status_code == 400
9899 assert res .json ()["detail" ] == "Machine with this name already exists"
99100
@@ -128,7 +129,7 @@ def test_endpoint_successfully_list_machines(self, client):
128129 "chrysalis" ,
129130 }
130131
131- res = client .get ("/api /machines" )
132+ res = client .get (f" { API_BASE } /machines" )
132133 assert res .status_code == 200
133134 data = res .json ()
134135
@@ -167,7 +168,7 @@ def test_endpoint_successfully_get_machine(self, client, db: Session):
167168 db .commit ()
168169 db .refresh (expected )
169170
170- res = client .get (f"/api /machines/{ expected .id } " )
171+ res = client .get (f"{ API_BASE } /machines/{ expected .id } " )
171172 assert res .status_code == 200
172173
173174 result_endpoint = res .json ()
@@ -185,6 +186,6 @@ def test_function_raises_error_if_machine_not_found(self, db: Session):
185186 def test_endpoint_raises_404_if_machine_not_found (self , client ):
186187 random_id = uuid4 ()
187188
188- res = client .get (f"/api /machines/{ random_id } " )
189+ res = client .get (f"{ API_BASE } /machines/{ random_id } " )
189190 assert res .status_code == 404
190191 assert res .json ()["detail" ] == "Machine not found"
0 commit comments