takahe/tests/api/test_likes.py

26 lines
676 B
Python
Raw Normal View History

2023-01-21 02:49:55 +00:00
import pytest
@pytest.mark.django_db
2023-02-14 02:40:10 +00:00
def test_likes_flow(api_client):
2023-01-21 02:49:55 +00:00
# Add a post
2023-02-14 02:40:10 +00:00
response = api_client.post(
2023-01-21 02:49:55 +00:00
"/api/v1/statuses",
content_type="application/json",
data={
"status": "Like test.",
"visibility": "public",
},
).json()
assert response["content"] == "<p>Like test.</p>"
status_id = response["id"]
# Like it
2023-02-14 02:40:10 +00:00
response = api_client.post(f"/api/v1/statuses/{status_id}/favourite").json()
2023-01-21 02:49:55 +00:00
assert response["favourited"] is True
# Check if it's displaying at likes endpoint
2023-02-14 02:40:10 +00:00
response = api_client.get("/api/v1/favourites").json()
2023-01-21 02:49:55 +00:00
assert response[0]["id"] == status_id