From 0d1e09fbcdb1a1db93d9561c9323c7ef105e71ca Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Mon, 21 Nov 2022 20:10:01 -0700 Subject: Refactor almost all tests into /tests/ --- activities/tests/__init__.py | 0 activities/tests/models/__init__.py | 0 activities/tests/models/test_post.py | 31 ---------------------- activities/tests/templatetags/__init__.py | 0 .../tests/templatetags/test_activity_tags.py | 21 --------------- 5 files changed, 52 deletions(-) delete mode 100644 activities/tests/__init__.py delete mode 100644 activities/tests/models/__init__.py delete mode 100644 activities/tests/models/test_post.py delete mode 100644 activities/tests/templatetags/__init__.py delete mode 100644 activities/tests/templatetags/test_activity_tags.py (limited to 'activities') diff --git a/activities/tests/__init__.py b/activities/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/activities/tests/models/__init__.py b/activities/tests/models/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/activities/tests/models/test_post.py b/activities/tests/models/test_post.py deleted file mode 100644 index 5c7fca2..0000000 --- a/activities/tests/models/test_post.py +++ /dev/null @@ -1,31 +0,0 @@ -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 diff --git a/activities/tests/templatetags/__init__.py b/activities/tests/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/activities/tests/templatetags/test_activity_tags.py b/activities/tests/templatetags/test_activity_tags.py deleted file mode 100644 index 987c008..0000000 --- a/activities/tests/templatetags/test_activity_tags.py +++ /dev/null @@ -1,21 +0,0 @@ -from datetime import timedelta - -from django.utils import timezone - -from activities.templatetags.activity_tags import timedeltashort - - -def test_timedeltashort_regress(): - assert timedeltashort(None) == "" - assert timedeltashort("") == "" - - value = timezone.now() - - assert timedeltashort(value) == "0s" - assert timedeltashort(value - timedelta(seconds=2)) == "2s" - assert timedeltashort(value - timedelta(minutes=2)) == "2m" - assert timedeltashort(value - timedelta(hours=2)) == "2h" - assert timedeltashort(value - timedelta(days=2)) == "2d" - assert timedeltashort(value - timedelta(days=364)) == "364d" - assert timedeltashort(value - timedelta(days=365)) == "1y" - assert timedeltashort(value - timedelta(days=366)) == "1y" -- cgit v1.2.3