class TestProfileAllStream(SocialhomeTestCase): @classmethod def setUpTestData(cls): super().setUpTestData() cls.create_local_and_remote_user() cls.create_content_set() cls.remote_profile_content = PublicContentFactory(author=cls.remote_profile) def setUp(self): super().setUp() self.stream = ProfileAllStream(user=self.user, profile=self.remote_profile) def test_get_content_ids__uses_cached_ids(self): with patch.object(self.stream, "get_cached_content_ids", return_value=([], {})) as mock_cached: self.stream.get_content_ids() mock_cached.assert_called_once_with() def test_get_queryset(self): qs = self.stream.get_queryset() self.assertEqual(set(qs), {self.remote_profile_content}) def test_get_target_streams(self): self.assertEqual( len(ProfileAllStream.get_target_streams(self.public_content, self.user, self.public_content.author)), 1, ) def test_key(self): self.assertEqual(self.stream.key, "sh:streams:profile_all:%s:%s" % (self.remote_profile.id, self.user.id))
def get_content(self): stream = ProfileAllStream( last_id=self.last_id, profile=self.profile, user=self.request.user, accept_ids=self.accept_ids, ) return stream.get_content()
def test_get_target_streams(self): self.assertEqual( len( ProfileAllStream.get_target_streams( self.public_content, self.user, self.public_content.author)), 1, )
def setUp(self): super().setUp() self.stream = ProfileAllStream(user=self.user, profile=self.remote_profile)
def test_get_target_streams(self): self.assertEqual( len(ProfileAllStream.get_target_streams(self.public_content, self.user, self.public_content.author)), 1, )
def setUp(self): super().setUp() self.stream = ProfileAllStream(user=self.user, profile=self.remote_profile)