diff options
author | Andrew Godwin | 2022-11-13 18:42:47 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-11-13 18:43:09 -0700 |
commit | ddb3436275d3f02183f515c38cd3193cd1dfe2f4 (patch) | |
tree | 8902d4f085ad6d8323f43af20ca497d291e4d28a /activities/tests | |
parent | 68c156fd2758da5831bd83bfb1249dd014d78177 (diff) | |
download | takahe-ddb3436275d3f02183f515c38cd3193cd1dfe2f4.tar.gz takahe-ddb3436275d3f02183f515c38cd3193cd1dfe2f4.tar.bz2 takahe-ddb3436275d3f02183f515c38cd3193cd1dfe2f4.zip |
Boosting! Incoming, anyway.
Diffstat (limited to 'activities/tests')
-rw-r--r-- | activities/tests/__init__.py | 0 | ||||
-rw-r--r-- | activities/tests/models/__init__.py | 0 | ||||
-rw-r--r-- | activities/tests/models/test_post.py | 31 |
3 files changed, 31 insertions, 0 deletions
diff --git a/activities/tests/__init__.py b/activities/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/activities/tests/__init__.py diff --git a/activities/tests/models/__init__.py b/activities/tests/models/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/activities/tests/models/__init__.py diff --git a/activities/tests/models/test_post.py b/activities/tests/models/test_post.py new file mode 100644 index 0000000..5c7fca2 --- /dev/null +++ b/activities/tests/models/test_post.py @@ -0,0 +1,31 @@ +import pytest +from pytest_httpx import HTTPXMock + +from activities.models import Post + + +@pytest.mark.django_db +def test_fetch_post(httpx_mock: HTTPXMock): + """ + Tests that a post we don't have locally can be fetched by by_object_uri + """ + httpx_mock.add_response( + url="https://example.com/test-post", + json={ + "@context": [ + "https://www.w3.org/ns/activitystreams", + ], + "id": "https://example.com/test-post", + "type": "Note", + "published": "2022-11-13T23:20:16Z", + "url": "https://example.com/test-post", + "attributedTo": "https://example.com/test-actor", + "content": "BEEEEEES", + }, + ) + # Fetch with a HTTP access + post = Post.by_object_uri("https://example.com/test-post", fetch=True) + assert post.content == "BEEEEEES" + assert post.author.actor_uri == "https://example.com/test-actor" + # Fetch again with a DB hit + assert Post.by_object_uri("https://example.com/test-post").id == post.id |