kopia lustrzana https://gitlab.com/marnanel/chapeau
Many new timeline tests, per spec
rodzic
312b3760fc
commit
f40a6d862d
|
@ -11,8 +11,10 @@ from rest_framework.test import APIClient, force_authenticate
|
|||
from kepi.trilby_api.views import *
|
||||
from kepi.trilby_api.tests import *
|
||||
from kepi.trilby_api.models import *
|
||||
from kepi.bowler_pub.tests import create_remote_person
|
||||
from django.conf import settings
|
||||
from unittest import skip
|
||||
import httpretty
|
||||
|
||||
# Tests for timelines. API docs are here:
|
||||
# https://docs.joinmastodon.org/methods/statuses/
|
||||
|
@ -29,9 +31,12 @@ class TestTimelines(TrilbyTestCase):
|
|||
|
||||
logger.info("Created status: %s", status)
|
||||
|
||||
return status
|
||||
|
||||
def timeline_contents(self,
|
||||
path,
|
||||
as_user):
|
||||
as_user = None,
|
||||
):
|
||||
|
||||
details = sorted([x['content'] \
|
||||
for x in self.get(
|
||||
|
@ -132,6 +137,146 @@ class TestTimelines(TrilbyTestCase):
|
|||
'A',
|
||||
)
|
||||
|
||||
@httpretty.activate()
|
||||
def test_public_local_and_remote(self):
|
||||
|
||||
alice = create_local_person("alice")
|
||||
peter = create_remote_person(
|
||||
remote_url = "https://example.com/users/peter",
|
||||
name = "peter",
|
||||
auto_fetch = True,
|
||||
)
|
||||
|
||||
self.add_status(source=alice, content='A', visibility='A')
|
||||
self.add_status(source=peter, content='B', visibility='A')
|
||||
self.add_status(source=alice, content='C', visibility='A')
|
||||
self.add_status(source=peter, content='D', visibility='A')
|
||||
|
||||
self.assertEqual(
|
||||
self.timeline_contents(
|
||||
path = '/api/v1/timelines/public',
|
||||
),
|
||||
'ABCD',
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
self.timeline_contents(
|
||||
path = '/api/v1/timelines/public?local=true',
|
||||
),
|
||||
'AC',
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
self.timeline_contents(
|
||||
path = '/api/v1/timelines/public?local=false',
|
||||
),
|
||||
'ABCD',
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
self.timeline_contents(
|
||||
path = '/api/v1/timelines/public?remote=true',
|
||||
),
|
||||
'BD',
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
self.timeline_contents(
|
||||
path = '/api/v1/timelines/public?remote=false',
|
||||
),
|
||||
'ABCD',
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
self.timeline_contents(
|
||||
path = '/api/v1/timelines/public?local=true&remote=true',
|
||||
),
|
||||
'',
|
||||
)
|
||||
|
||||
def test_public_only_media(self):
|
||||
|
||||
# We don't support added media at present anyway,
|
||||
# so turning this on will always get the empty set
|
||||
|
||||
alice = create_local_person("alice")
|
||||
|
||||
self.add_status(source=alice, content='A', visibility='A')
|
||||
self.add_status(source=alice, content='B', visibility='A')
|
||||
self.add_status(source=alice, content='C', visibility='A')
|
||||
self.add_status(source=alice, content='D', visibility='A')
|
||||
|
||||
self.assertEqual(
|
||||
self.timeline_contents(
|
||||
path = '/api/v1/timelines/public?only_media=true',
|
||||
),
|
||||
'',
|
||||
)
|
||||
|
||||
def test_public_max_since_and_min(self):
|
||||
|
||||
alice = create_local_person("alice")
|
||||
|
||||
self.add_status(source=alice, content='A', visibility='A')
|
||||
self.add_status(source=alice, content='B', visibility='A')
|
||||
status_c = self.add_status(source=alice, content='C', visibility='A')
|
||||
self.add_status(source=alice, content='D', visibility='A')
|
||||
|
||||
c_id = str(status_c.id)
|
||||
|
||||
self.assertEqual(
|
||||
self.timeline_contents(
|
||||
path = '/api/v1/timelines/public?since='+c_id,
|
||||
),
|
||||
'D',
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
self.timeline_contents(
|
||||
path = '/api/v1/timelines/public?max_id='+c_id,
|
||||
),
|
||||
'ABC',
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
self.timeline_contents(
|
||||
path = '/api/v1/timelines/public?min_id='+c_id,
|
||||
),
|
||||
'CD',
|
||||
)
|
||||
|
||||
def test_public_limit(self):
|
||||
|
||||
alice = create_local_person("alice")
|
||||
|
||||
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
|
||||
for i in range(len(alphabet)):
|
||||
self.add_status(
|
||||
source=alice,
|
||||
content=alphabet[i],
|
||||
visibility='A',
|
||||
)
|
||||
|
||||
for i in range(len(alphabet)):
|
||||
self.assertEqual(
|
||||
self.timeline_contents(
|
||||
path = '/api/v1/timelines/public?limit='+str(i),
|
||||
),
|
||||
alphabet[:i],
|
||||
)
|
||||
|
||||
# the default is specified as 20
|
||||
self.assertEqual(
|
||||
self.timeline_contents(
|
||||
path = '/api/v1/timelines/public',
|
||||
),
|
||||
alphabet[:20],
|
||||
message = 'default is 20',
|
||||
)
|
||||
|
||||
###### home timeline
|
||||
|
||||
def test_home_as_user(self):
|
||||
alice = create_local_person("alice")
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue