mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 10:01:04 +00:00
Updates tests
This commit is contained in:
parent
9d75bc3982
commit
9d19092205
4 changed files with 18 additions and 10 deletions
|
@ -7,6 +7,7 @@ from bookwyrm.redis_store import RedisStore, r
|
|||
from bookwyrm.settings import STREAMS
|
||||
from bookwyrm.views.helpers import privacy_filter
|
||||
|
||||
|
||||
class ActivityStream(RedisStore):
|
||||
"""a category of activity stream (like home, local, federated)"""
|
||||
|
||||
|
@ -219,12 +220,17 @@ class BooksStream(ActivityStream):
|
|||
|
||||
|
||||
available_streams = [s["key"] for s in STREAMS]
|
||||
streams = {k:v for (k, v) in {
|
||||
"home": HomeStream(),
|
||||
"local": LocalStream(),
|
||||
"federated": FederatedStream(),
|
||||
"books": BooksStream(),
|
||||
}.items() if k in available_streams}
|
||||
streams = {
|
||||
k: v
|
||||
for (k, v) in {
|
||||
"home": HomeStream(),
|
||||
"local": LocalStream(),
|
||||
"federated": FederatedStream(),
|
||||
"books": BooksStream(),
|
||||
}.items()
|
||||
if k in available_streams
|
||||
}
|
||||
|
||||
|
||||
@receiver(signals.post_save)
|
||||
# pylint: disable=unused-argument
|
||||
|
|
|
@ -46,4 +46,4 @@ class Activitystreams(TestCase):
|
|||
"bookwyrm.activitystreams.ActivityStream.populate_store"
|
||||
) as redis_mock:
|
||||
populate_streams()
|
||||
self.assertEqual(redis_mock.call_count, 6) # 2 users x 3 streams
|
||||
self.assertEqual(redis_mock.call_count, 4) # 2 users x 2 streams
|
||||
|
|
|
@ -45,7 +45,7 @@ class FeedViews(TestCase):
|
|||
view = views.Feed.as_view()
|
||||
request = self.factory.get("")
|
||||
request.user = self.local_user
|
||||
result = view(request, "local")
|
||||
result = view(request, "home")
|
||||
self.assertIsInstance(result, TemplateResponse)
|
||||
result.render()
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
|
|
@ -24,9 +24,11 @@ class Feed(View):
|
|||
def get(self, request, tab):
|
||||
"""user's homepage with activity feed"""
|
||||
tab = [s for s in STREAMS if s["key"] == tab]
|
||||
tab = tab[0] or STREAMS[0]
|
||||
tab = tab[0] if tab else STREAMS[0]
|
||||
|
||||
activities = activitystreams.streams[tab["key"]].get_activity_stream(request.user)
|
||||
activities = activitystreams.streams[tab["key"]].get_activity_stream(
|
||||
request.user
|
||||
)
|
||||
paginated = Paginator(activities, PAGE_LENGTH)
|
||||
|
||||
suggestions = suggested_users.get_suggestions(request.user)
|
||||
|
|
Loading…
Reference in a new issue