From a5848e45e2a8f04827473a15b3319d888a389f2c Mon Sep 17 00:00:00 2001 From: Marnanel Thurman Date: Thu, 18 Feb 2021 18:37:43 +0000 Subject: [PATCH] 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. --- kepi/trilby_api/tests/test_timelines.py | 122 ++++++++++-------------- 1 file changed, 48 insertions(+), 74 deletions(-) diff --git a/kepi/trilby_api/tests/test_timelines.py b/kepi/trilby_api/tests/test_timelines.py index 54ef8fc..0bb869b 100644 --- a/kepi/trilby_api/tests/test_timelines.py +++ b/kepi/trilby_api/tests/test_timelines.py @@ -1,7 +1,7 @@ # test_timelines.py # # Part of kepi. -# Copyright (c) 2018-2020 Marnanel Thurman. +# Copyright (c) 2018-2021 Marnanel Thurman. # Licensed under the GNU Public License v2. import logging @@ -16,8 +16,10 @@ from django.conf import settings from unittest import skip 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): @@ -107,31 +109,6 @@ class TestPublicTimeline(TimelineTestCase): '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): alice = create_local_person("alice") @@ -248,7 +225,7 @@ class TestPublicTimeline(TimelineTestCase): self.assertEqual( self.timeline_contents( path = '/api/v1/timelines/public', - data = {'since': status_c.id}, + data = {'since_id': status_c.id}, ), 'D', ) @@ -361,7 +338,7 @@ class TestHomeTimeline(TimelineTestCase): self.assertEqual( self.timeline_contents( path = '/api/v1/timelines/home', - data = {'since': c_id}, + data = {'since_id': c_id}, as_user = self.alice, ), 'D', @@ -390,7 +367,7 @@ class TestHomeTimeline(TimelineTestCase): self.assertEqual( self.timeline_contents( path = '/api/v1/timelines/home', - data = {'since': c_id}, + data = {'since_id': c_id}, as_user = self.alice, ), 'D', @@ -460,49 +437,6 @@ class TestHomeTimeline(TimelineTestCase): 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() def test_local(self): @@ -545,6 +479,46 @@ class TestHomeTimeline(TimelineTestCase): '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): @skip("to be implemented later") def test_hashtag(self):