From 3fef35a0ec333d02de8a9a9d3c3fb37df9a08f01 Mon Sep 17 00:00:00 2001 From: Alexis Feron Date: Tue, 28 Jan 2025 14:56:16 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Update=20pin=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/dto/PinDTO.py | 2 +- app/models/pin.py | 2 +- tests/test_pins.py | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/dto/PinDTO.py b/app/dto/PinDTO.py index c30ddbd..e7b32d4 100644 --- a/app/dto/PinDTO.py +++ b/app/dto/PinDTO.py @@ -3,5 +3,5 @@ from pydantic import BaseModel class PinDTO(BaseModel): title: str description: str - location: str + location: list files: list \ No newline at end of file diff --git a/app/models/pin.py b/app/models/pin.py index ec4677f..33b2d1c 100644 --- a/app/models/pin.py +++ b/app/models/pin.py @@ -5,5 +5,5 @@ class Pin(BaseModel): id: Optional[str] title: str description: str - location: str + location: list files: Optional[list] \ No newline at end of file diff --git a/tests/test_pins.py b/tests/test_pins.py index 2e96ec9..ba3f316 100644 --- a/tests/test_pins.py +++ b/tests/test_pins.py @@ -1,7 +1,7 @@ from test_main import * def test_add_pin(token): - response = client.post("/pin/add", json={"title": "Test Pin", "description": "Test Description", "location": "Test location", "files": ["Test file 1"]}, headers={"Authorization": f"Bearer {token}"}) + response = client.post("/pin/add", json={"title": "Test Pin", "description": "Test Description", "location": [0,0], "files": ["Test file 1"]}, headers={"Authorization": f"Bearer {token}"}) assert response.status_code == 200 data = response.json() assert "id" in data @@ -13,7 +13,7 @@ def test_list_pins(token): assert isinstance(data, list) def test_get_pin(token): - add_pin_response = client.post("/pin/add", json={"title": "Test Pin", "description": "Test Description", "location": "Test location", "files": ["Test file 1"]}, headers={"Authorization": f"Bearer {token}"}) + add_pin_response = client.post("/pin/add", json={"title": "Test Pin", "description": "Test Description", "location": [0,0], "files": ["Test file 1"]}, headers={"Authorization": f"Bearer {token}"}) pin_id = add_pin_response.json()["id"] response = client.get(f"/pin/{pin_id}", headers={"Authorization": f"Bearer {token}"}) @@ -21,7 +21,7 @@ def test_get_pin(token): data = response.json() assert data["title"] == "Test Pin" assert data["description"] == "Test Description" - assert data["location"] == "Test location" + assert data["location"] == [0,0] assert data["files"] == ["Test file 1"] @@ -36,17 +36,17 @@ def test_get_pin_unknown_id(token): def test_update_pin(token): - add_pin_response = client.post("/pin/add", json={"title": "Test Pin", "description": "Test Description", "location": "Test location", "files": ["Test file 1"]}, headers={"Authorization": f"Bearer {token}"}) + add_pin_response = client.post("/pin/add", json={"title": "Test Pin", "description": "Test Description", "location": [0,0], "files": ["Test file 1"]}, headers={"Authorization": f"Bearer {token}"}) pin_id = add_pin_response.json()["id"] - update_response = client.patch(f"/pin/{pin_id}", json={"title": "Updated Pin", "description": "Updated Description", "location": "Updated location", "files": ["Updated file 1"]}, headers={"Authorization": f"Bearer {token}"}) + update_response = client.patch(f"/pin/{pin_id}", json={"title": "Updated Pin", "description": "Updated Description", "location": [0,1], "files": ["Updated file 1"]}, headers={"Authorization": f"Bearer {token}"}) assert update_response.status_code == 200 get_pin_response = client.get(f"/pin/{pin_id}", headers={"Authorization": f"Bearer {token}"}) data = get_pin_response.json() assert data["title"] == "Updated Pin" assert data["description"] == "Updated Description" - assert data["location"] == "Updated location" + assert data["location"] == [0,1] assert data["files"] == ["Updated file 1"]