|
|
@ -55,7 +55,7 @@ def test_add_pin():
|
|
|
|
login_response = client.post("/login", data={"username": "testuser", "password": "testpassword"})
|
|
|
|
login_response = client.post("/login", data={"username": "testuser", "password": "testpassword"})
|
|
|
|
token = login_response.json()["access_token"]
|
|
|
|
token = login_response.json()["access_token"]
|
|
|
|
|
|
|
|
|
|
|
|
response = client.post("/pin/add", json={"title": "Test Pin", "description": "Test Description"}, headers={"Authorization": f"Bearer {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}"})
|
|
|
|
assert response.status_code == 200
|
|
|
|
assert response.status_code == 200
|
|
|
|
data = response.json()
|
|
|
|
data = response.json()
|
|
|
|
assert "id" in data
|
|
|
|
assert "id" in data
|
|
|
@ -73,7 +73,7 @@ def test_get_pin():
|
|
|
|
login_response = client.post("/login", data={"username": "testuser", "password": "testpassword"})
|
|
|
|
login_response = client.post("/login", data={"username": "testuser", "password": "testpassword"})
|
|
|
|
token = login_response.json()["access_token"]
|
|
|
|
token = login_response.json()["access_token"]
|
|
|
|
|
|
|
|
|
|
|
|
add_pin_response = client.post("/pin/add", json={"title": "Test Pin", "description": "Test Description"}, headers={"Authorization": f"Bearer {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}"})
|
|
|
|
pin_id = add_pin_response.json()["id"]
|
|
|
|
pin_id = add_pin_response.json()["id"]
|
|
|
|
|
|
|
|
|
|
|
|
response = client.get(f"/pin/{pin_id}", headers={"Authorization": f"Bearer {token}"})
|
|
|
|
response = client.get(f"/pin/{pin_id}", headers={"Authorization": f"Bearer {token}"})
|
|
|
@ -81,6 +81,8 @@ def test_get_pin():
|
|
|
|
data = response.json()
|
|
|
|
data = response.json()
|
|
|
|
assert data["title"] == "Test Pin"
|
|
|
|
assert data["title"] == "Test Pin"
|
|
|
|
assert data["description"] == "Test Description"
|
|
|
|
assert data["description"] == "Test Description"
|
|
|
|
|
|
|
|
assert data["location"] == "Test location"
|
|
|
|
|
|
|
|
assert data["files"] == ["Test file 1"]
|
|
|
|
|
|
|
|
|
|
|
|
# Test wrong format
|
|
|
|
# Test wrong format
|
|
|
|
response = client.get(f"/pin/randomIdThatDoesntExists", headers={"Authorization": f"Bearer {token}"})
|
|
|
|
response = client.get(f"/pin/randomIdThatDoesntExists", headers={"Authorization": f"Bearer {token}"})
|
|
|
@ -95,16 +97,18 @@ def test_update_pin():
|
|
|
|
login_response = client.post("/login", data={"username": "testuser", "password": "testpassword"})
|
|
|
|
login_response = client.post("/login", data={"username": "testuser", "password": "testpassword"})
|
|
|
|
token = login_response.json()["access_token"]
|
|
|
|
token = login_response.json()["access_token"]
|
|
|
|
|
|
|
|
|
|
|
|
add_pin_response = client.post("/pin/add", json={"title": "Test Pin", "description": "Test Description"}, headers={"Authorization": f"Bearer {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}"})
|
|
|
|
pin_id = add_pin_response.json()["id"]
|
|
|
|
pin_id = add_pin_response.json()["id"]
|
|
|
|
|
|
|
|
|
|
|
|
update_response = client.patch(f"/pin/{pin_id}", json={"title": "Updated Pin", "description": "Updated Description"}, headers={"Authorization": f"Bearer {token}"})
|
|
|
|
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}"})
|
|
|
|
assert update_response.status_code == 200
|
|
|
|
assert update_response.status_code == 200
|
|
|
|
|
|
|
|
|
|
|
|
get_pin_response = client.get(f"/pin/{pin_id}", headers={"Authorization": f"Bearer {token}"})
|
|
|
|
get_pin_response = client.get(f"/pin/{pin_id}", headers={"Authorization": f"Bearer {token}"})
|
|
|
|
data = get_pin_response.json()
|
|
|
|
data = get_pin_response.json()
|
|
|
|
assert data["title"] == "Updated Pin"
|
|
|
|
assert data["title"] == "Updated Pin"
|
|
|
|
assert data["description"] == "Updated Description"
|
|
|
|
assert data["description"] == "Updated Description"
|
|
|
|
|
|
|
|
assert data["location"] == "Updated location"
|
|
|
|
|
|
|
|
assert data["files"] == ["Updated file 1"]
|
|
|
|
|
|
|
|
|
|
|
|
# Test wrong format
|
|
|
|
# Test wrong format
|
|
|
|
response = client.get(f"/pin/randomIdThatDoesntExists", headers={"Authorization": f"Bearer {token}"})
|
|
|
|
response = client.get(f"/pin/randomIdThatDoesntExists", headers={"Authorization": f"Bearer {token}"})
|
|
|
|