|
|
|
@ -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": [0,0], "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"], "user_id": "6798e24b9d212d0f6a6b0abd"}, 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": [0,0], "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"], "user_id": "6798e24b9d212d0f6a6b0abd"}, headers={"Authorization": f"Bearer {token}"})
|
|
|
|
|
pin_id = add_pin_response.json()["id"]
|
|
|
|
|
|
|
|
|
|
response = client.get(f"/pin/{pin_id}", headers={"Authorization": f"Bearer {token}"})
|
|
|
|
@ -23,6 +23,7 @@ def test_get_pin(token):
|
|
|
|
|
assert data["description"] == "Test Description"
|
|
|
|
|
assert data["location"] == [0,0]
|
|
|
|
|
assert data["files"] == ["Test file 1"]
|
|
|
|
|
assert data["user_id"] == "6798e24b9d212d0f6a6b0abd"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_pin_wrong_format(token):
|
|
|
|
@ -36,10 +37,10 @@ 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": [0,0], "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"], "user_id": "6798e24b9d212d0f6a6b0abd"}, 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": [0,1], "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"], "user_id": "6798e24b9d212d0f6a6b0abd"}, 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}"})
|
|
|
|
@ -48,6 +49,7 @@ def test_update_pin(token):
|
|
|
|
|
assert data["description"] == "Updated Description"
|
|
|
|
|
assert data["location"] == [0,1]
|
|
|
|
|
assert data["files"] == ["Updated file 1"]
|
|
|
|
|
assert data["user_id"] == "6798e24b9d212d0f6a6b0abd"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_update_wrong_format(token):
|
|
|
|
|