🔨 Update pin model
continuous-integration/drone/push Build is passing Details

master
Alexis Feron 3 months ago
parent 49a2a9b823
commit 3fef35a0ec

@ -3,5 +3,5 @@ from pydantic import BaseModel
class PinDTO(BaseModel):
title: str
description: str
location: str
location: list
files: list

@ -5,5 +5,5 @@ class Pin(BaseModel):
id: Optional[str]
title: str
description: str
location: str
location: list
files: Optional[list]

@ -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"]

Loading…
Cancel
Save