forked from jointakahe/takahe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
18 changed files
with
275 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block title%}{{ title }}{% endblock %} | ||
|
||
{% block content %} | ||
<h1>{{ title }}</h1> | ||
{{ content }} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
import asyncio | ||
|
||
import pytest | ||
from asgiref.sync import async_to_sync | ||
from pytest_httpx import HTTPXMock | ||
|
||
from activities.models import Post, PostStates | ||
|
@@ -128,21 +125,8 @@ def test_linkify_mentions_local(identity, remote_identity): | |
assert post.safe_content_local() == "<p>@[email protected], welcome!</p>" | ||
|
||
|
||
async def stator_process_tasks(stator): | ||
""" | ||
Guarded wrapper to simply async_to_sync and ensure all stator tasks are | ||
run to completion without blocking indefinitely. | ||
""" | ||
await asyncio.wait_for(stator.fetch_and_process_tasks(), timeout=1) | ||
for _ in range(100): | ||
if not stator.tasks: | ||
break | ||
stator.remove_completed_tasks() | ||
await asyncio.sleep(0.01) | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_post_transitions(identity, stator_runner): | ||
def test_post_transitions(identity, stator): | ||
|
||
# Create post | ||
post = Post.objects.create( | ||
|
@@ -153,18 +137,18 @@ def test_post_transitions(identity, stator_runner): | |
) | ||
# Test: | --> new --> fanned_out | ||
assert post.state == str(PostStates.new) | ||
async_to_sync(stator_process_tasks)(stator_runner) | ||
stator.run_single_cycle_sync() | ||
post = Post.objects.get(id=post.id) | ||
assert post.state == str(PostStates.fanned_out) | ||
|
||
# Test: fanned_out --> (forced) edited --> edited_fanned_out | ||
Post.transition_perform(post, PostStates.edited) | ||
async_to_sync(stator_process_tasks)(stator_runner) | ||
stator.run_single_cycle_sync() | ||
post = Post.objects.get(id=post.id) | ||
assert post.state == str(PostStates.edited_fanned_out) | ||
|
||
# Test: edited_fanned_out --> (forced) deleted --> deleted_fanned_out | ||
Post.transition_perform(post, PostStates.deleted) | ||
async_to_sync(stator_process_tasks)(stator_runner) | ||
stator.run_single_cycle_sync() | ||
post = Post.objects.get(id=post.id) | ||
assert post.state == str(PostStates.deleted_fanned_out) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.