fix api
This commit is contained in:
parent
2cc7689e8e
commit
396c25317a
@ -43,8 +43,7 @@ COPY --from=ghcr.io/astral-sh/uv:0.5.18 /uv /uvx /bin/
|
|||||||
|
|
||||||
WORKDIR $APP_HOME
|
WORKDIR $APP_HOME
|
||||||
|
|
||||||
RUN uv sync --frozen --dev && \
|
RUN uv sync --frozen --dev
|
||||||
rm -rf $APP_HOME
|
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
|
33
compose.yml
Normal file
33
compose.yml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
services:
|
||||||
|
teufa:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
develop:
|
||||||
|
watch:
|
||||||
|
- action: sync+restart
|
||||||
|
path: .
|
||||||
|
target: /opt/app
|
||||||
|
ignore:
|
||||||
|
- .venv/
|
||||||
|
- action: rebuild
|
||||||
|
path: ./pyproject.toml
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: postgresql+psycopg://postgres:changeme@db:5432/postgres
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
db:
|
||||||
|
image: postgres:16
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: changeme
|
||||||
|
POSTGRES_DB: teufa
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
migrate:
|
||||||
|
image: teufa:latest
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: postgresql+psycopg://postgres:changeme@db:5432/postgres
|
||||||
|
command: alembic upgrade head
|
@ -30,7 +30,7 @@ def test_create_flight(client: FlaskClient):
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert response.status_code == 201
|
assert response.status_code == 201
|
||||||
assert json.loads(response.json) == {
|
assert response.json == {
|
||||||
"flight": {
|
"flight": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"departure_icao": "KDEN",
|
"departure_icao": "KDEN",
|
||||||
@ -63,7 +63,7 @@ def test_get_flight(client: FlaskClient):
|
|||||||
response = client.get("/api/v1/flights/1")
|
response = client.get("/api/v1/flights/1")
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert json.loads(response.json) == {
|
assert response.json == {
|
||||||
"flight": {
|
"flight": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"departure_icao": "KDEN",
|
"departure_icao": "KDEN",
|
||||||
@ -77,7 +77,7 @@ def test_get_flight_not_found(client: FlaskClient):
|
|||||||
response = client.get("/api/v1/flights/1")
|
response = client.get("/api/v1/flights/1")
|
||||||
|
|
||||||
assert response.status_code == 404
|
assert response.status_code == 404
|
||||||
assert json.loads(response.json) == {"message": "Flight not found"}
|
assert response.json == {"message": "Flight not found"}
|
||||||
|
|
||||||
|
|
||||||
def test_update_flight(client: FlaskClient):
|
def test_update_flight(client: FlaskClient):
|
||||||
@ -112,7 +112,7 @@ def test_update_flight(client: FlaskClient):
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert json.loads(response.json) == {
|
assert response.json == {
|
||||||
"flight": {
|
"flight": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"departure_icao": "KJFK",
|
"departure_icao": "KJFK",
|
||||||
@ -134,7 +134,7 @@ def test_update_flight_not_found(client: FlaskClient):
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert response.status_code == 404
|
assert response.status_code == 404
|
||||||
assert json.loads(response.json) == {"message": "Flight not found"}
|
assert response.json == {"message": "Flight not found"}
|
||||||
|
|
||||||
|
|
||||||
def test_delete_flight(client: FlaskClient):
|
def test_delete_flight(client: FlaskClient):
|
||||||
@ -170,4 +170,4 @@ def test_delete_flight_not_found(client: FlaskClient):
|
|||||||
response = client.delete("/api/v1/flights/1")
|
response = client.delete("/api/v1/flights/1")
|
||||||
|
|
||||||
assert response.status_code == 404
|
assert response.status_code == 404
|
||||||
assert json.loads(response.json) == {"message": "Flight not found"}
|
assert response.json == {"message": "Flight not found"}
|
||||||
|
@ -33,7 +33,7 @@ class FlightCollectionResource(Resource):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
return res.model_dump_json(), 201
|
return res.model_dump(), 201
|
||||||
|
|
||||||
|
|
||||||
class FlightResource(Resource):
|
class FlightResource(Resource):
|
||||||
@ -41,7 +41,7 @@ class FlightResource(Resource):
|
|||||||
flight = db.session.get(dbm.Flight, flight_id)
|
flight = db.session.get(dbm.Flight, flight_id)
|
||||||
|
|
||||||
if not flight:
|
if not flight:
|
||||||
return dao.Error(message="Flight not found").model_dump_json(), 404
|
return dao.Error(message="Flight not found").model_dump(), 404
|
||||||
|
|
||||||
res = dao.GetFlightResponse(
|
res = dao.GetFlightResponse(
|
||||||
**{
|
**{
|
||||||
@ -54,13 +54,13 @@ class FlightResource(Resource):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
return res.model_dump_json()
|
return res.model_dump()
|
||||||
|
|
||||||
def put(self, flight_id):
|
def put(self, flight_id):
|
||||||
flight = db.session.get(dbm.Flight, flight_id)
|
flight = db.session.get(dbm.Flight, flight_id)
|
||||||
|
|
||||||
if not flight:
|
if not flight:
|
||||||
return dao.Error(message="Flight not found").model_dump_json(), 404
|
return dao.Error(message="Flight not found").model_dump(), 404
|
||||||
|
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
|
|
||||||
@ -88,13 +88,13 @@ class FlightResource(Resource):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
return res.model_dump_json()
|
return res.model_dump()
|
||||||
|
|
||||||
def delete(self, flight_id):
|
def delete(self, flight_id):
|
||||||
flight = db.session.get(dbm.Flight, flight_id)
|
flight = db.session.get(dbm.Flight, flight_id)
|
||||||
|
|
||||||
if not flight:
|
if not flight:
|
||||||
return dao.Error(message="Flight not found").model_dump_json(), 404
|
return dao.Error(message="Flight not found").model_dump(), 404
|
||||||
|
|
||||||
db.session.delete(flight)
|
db.session.delete(flight)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user