kopia lustrzana https://gitlab.com/marnanel/chapeau
test_as_follower moved to home timeline test, rather than public timeline test.
Test of "since" param, which doesn't exist, replaced with the correct "since_id". Removed a lot of debug code that shouldn't have been checked in. Fixed some comments.merge-requests/2/head
rodzic
46b3dcfbf7
commit
a5848e45e2
|
@ -1,7 +1,7 @@
|
||||||
# test_timelines.py
|
# test_timelines.py
|
||||||
#
|
#
|
||||||
# Part of kepi.
|
# Part of kepi.
|
||||||
# Copyright (c) 2018-2020 Marnanel Thurman.
|
# Copyright (c) 2018-2021 Marnanel Thurman.
|
||||||
# Licensed under the GNU Public License v2.
|
# Licensed under the GNU Public License v2.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
@ -16,8 +16,10 @@ from django.conf import settings
|
||||||
from unittest import skip
|
from unittest import skip
|
||||||
import httpretty
|
import httpretty
|
||||||
|
|
||||||
# Tests for timelines. API docs are here:
|
"""
|
||||||
# https://docs.joinmastodon.org/methods/statuses/
|
Tests for timelines. API docs are here:
|
||||||
|
https://docs.joinmastodon.org/methods/timelines/
|
||||||
|
"""
|
||||||
|
|
||||||
class TimelineTestCase(TrilbyTestCase):
|
class TimelineTestCase(TrilbyTestCase):
|
||||||
|
|
||||||
|
@ -107,31 +109,6 @@ class TestPublicTimeline(TimelineTestCase):
|
||||||
'A',
|
'A',
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_as_follower(self):
|
|
||||||
|
|
||||||
alice = create_local_person("alice")
|
|
||||||
george = create_local_person("george")
|
|
||||||
|
|
||||||
follow = Follow(
|
|
||||||
follower = george,
|
|
||||||
following = alice,
|
|
||||||
offer = None,
|
|
||||||
)
|
|
||||||
follow.save()
|
|
||||||
|
|
||||||
self.add_status(source=alice, content='A', visibility='A')
|
|
||||||
self.add_status(source=alice, content='B', visibility='U')
|
|
||||||
self.add_status(source=alice, content='C', visibility='X')
|
|
||||||
self.add_status(source=alice, content='D', visibility='D')
|
|
||||||
|
|
||||||
self.assertEqual(
|
|
||||||
self.timeline_contents(
|
|
||||||
path = '/api/v1/timelines/public',
|
|
||||||
as_user = george,
|
|
||||||
),
|
|
||||||
'AC',
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_as_stranger(self):
|
def test_as_stranger(self):
|
||||||
|
|
||||||
alice = create_local_person("alice")
|
alice = create_local_person("alice")
|
||||||
|
@ -248,7 +225,7 @@ class TestPublicTimeline(TimelineTestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.timeline_contents(
|
self.timeline_contents(
|
||||||
path = '/api/v1/timelines/public',
|
path = '/api/v1/timelines/public',
|
||||||
data = {'since': status_c.id},
|
data = {'since_id': status_c.id},
|
||||||
),
|
),
|
||||||
'D',
|
'D',
|
||||||
)
|
)
|
||||||
|
@ -361,7 +338,7 @@ class TestHomeTimeline(TimelineTestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.timeline_contents(
|
self.timeline_contents(
|
||||||
path = '/api/v1/timelines/home',
|
path = '/api/v1/timelines/home',
|
||||||
data = {'since': c_id},
|
data = {'since_id': c_id},
|
||||||
as_user = self.alice,
|
as_user = self.alice,
|
||||||
),
|
),
|
||||||
'D',
|
'D',
|
||||||
|
@ -390,7 +367,7 @@ class TestHomeTimeline(TimelineTestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.timeline_contents(
|
self.timeline_contents(
|
||||||
path = '/api/v1/timelines/home',
|
path = '/api/v1/timelines/home',
|
||||||
data = {'since': c_id},
|
data = {'since_id': c_id},
|
||||||
as_user = self.alice,
|
as_user = self.alice,
|
||||||
),
|
),
|
||||||
'D',
|
'D',
|
||||||
|
@ -460,49 +437,6 @@ class TestHomeTimeline(TimelineTestCase):
|
||||||
msg = 'default is 20',
|
msg = 'default is 20',
|
||||||
)
|
)
|
||||||
|
|
||||||
def temp_general_test_limit(self, count):
|
|
||||||
# XXX temp
|
|
||||||
|
|
||||||
self.alice = create_local_person("alice")
|
|
||||||
self.bob = create_local_person("bob")
|
|
||||||
self.carol = create_local_person("carol")
|
|
||||||
|
|
||||||
Follow(
|
|
||||||
follower=self.alice,
|
|
||||||
following=self.bob,
|
|
||||||
offer=None).save()
|
|
||||||
|
|
||||||
for i in range(100):
|
|
||||||
self.add_status(
|
|
||||||
source=self.bob,
|
|
||||||
content=str(i),
|
|
||||||
visibility='A',
|
|
||||||
)
|
|
||||||
|
|
||||||
self.add_status(
|
|
||||||
source=self.carol,
|
|
||||||
content=str(i),
|
|
||||||
visibility='A',
|
|
||||||
)
|
|
||||||
|
|
||||||
LOOP_COUNT = 50
|
|
||||||
for j in range(LOOP_COUNT):
|
|
||||||
logger.info("----------- Loop: %d of %d", j, LOOP_COUNT)
|
|
||||||
for i in [count]:
|
|
||||||
self.assertIsNotNone(
|
|
||||||
self.timeline_contents(
|
|
||||||
path = '/api/v1/timelines/home',
|
|
||||||
data = {'limit': i},
|
|
||||||
as_user = self.alice,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
def xxx_test_1(self):
|
|
||||||
self.temp_general_test_limit(1)
|
|
||||||
|
|
||||||
def xxx_test_100(self):
|
|
||||||
self.temp_general_test_limit(100)
|
|
||||||
|
|
||||||
@httpretty.activate()
|
@httpretty.activate()
|
||||||
def test_local(self):
|
def test_local(self):
|
||||||
|
|
||||||
|
@ -545,6 +479,46 @@ class TestHomeTimeline(TimelineTestCase):
|
||||||
'AD',
|
'AD',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_as_follower(self):
|
||||||
|
|
||||||
|
alice = create_local_person("alice")
|
||||||
|
george = create_local_person("george")
|
||||||
|
|
||||||
|
follow = Follow(
|
||||||
|
follower = george,
|
||||||
|
following = alice,
|
||||||
|
offer = None,
|
||||||
|
)
|
||||||
|
follow.save()
|
||||||
|
|
||||||
|
self.add_status(source=alice, content='A', visibility='A')
|
||||||
|
self.add_status(source=alice, content='B', visibility='U')
|
||||||
|
self.add_status(source=alice, content='C', visibility='X')
|
||||||
|
self.add_status(source=alice, content='D', visibility='D')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
self.timeline_contents(
|
||||||
|
path = '/api/v1/timelines/home',
|
||||||
|
as_user = george,
|
||||||
|
),
|
||||||
|
'A',
|
||||||
|
)
|
||||||
|
|
||||||
|
follow = Follow(
|
||||||
|
follower = alice,
|
||||||
|
following = george,
|
||||||
|
offer = None,
|
||||||
|
)
|
||||||
|
follow.save() # they are now mutuals
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
self.timeline_contents(
|
||||||
|
path = '/api/v1/timelines/home',
|
||||||
|
as_user = george,
|
||||||
|
),
|
||||||
|
'AC',
|
||||||
|
)
|
||||||
|
|
||||||
class TestTimelinesNotImplemented(TimelineTestCase):
|
class TestTimelinesNotImplemented(TimelineTestCase):
|
||||||
@skip("to be implemented later")
|
@skip("to be implemented later")
|
||||||
def test_hashtag(self):
|
def test_hashtag(self):
|
||||||
|
|
Ładowanie…
Reference in New Issue