Beispiel #1
0
class TestProfilePinnedStream(SocialhomeTestCase):
    @classmethod
    def setUpTestData(cls):
        super().setUpTestData()
        cls.create_local_and_remote_user()
        cls.create_content_set()
        cls.pinned_content = PublicContentFactory(author=cls.profile, pinned=True)
        cls.non_pinned_content = PublicContentFactory(author=cls.profile)

    def setUp(self):
        super().setUp()
        self.stream = ProfilePinnedStream(user=self.user, profile=self.profile)

    def test_get_content_ids__does_not_use_cached_ids(self):
        with patch.object(self.stream, "get_cached_content_ids") as mock_cached:
            self.stream.get_content_ids()
            self.assertFalse(mock_cached.called)

    def test_get_queryset(self):
        qs = self.stream.get_queryset()
        self.assertEqual(set(qs), {self.pinned_content})

    def test_get_target_streams(self):
        self.assertEqual(
            len(ProfilePinnedStream.get_target_streams(self.pinned_content, self.user, self.pinned_content.author)), 1,
        )

    def test_key(self):
        self.assertEqual(self.stream.key, "sh:streams:profile_pinned:%s:%s" % (self.profile.id, self.user.id))
Beispiel #2
0
 def get_content(self):
     stream = ProfilePinnedStream(
         last_id=self.last_id,
         profile=self.profile,
         user=self.request.user,
         accept_ids=self.accept_ids,
     )
     return stream.get_content()
Beispiel #3
0
 def test_get_target_streams(self):
     self.assertEqual(
         len(
             ProfilePinnedStream.get_target_streams(
                 self.pinned_content, self.user,
                 self.pinned_content.author)),
         1,
     )
Beispiel #4
0
 def setUp(self):
     super().setUp()
     self.stream = ProfilePinnedStream(user=self.user, profile=self.profile)
Beispiel #5
0
 def test_get_target_streams(self):
     self.assertEqual(
         len(ProfilePinnedStream.get_target_streams(self.pinned_content, self.user, self.pinned_content.author)), 1,
     )
Beispiel #6
0
 def setUp(self):
     super().setUp()
     self.stream = ProfilePinnedStream(user=self.user, profile=self.profile)