Пример #1
0
    def test_profile_entries_created(self):
        """
        Get the created entries for a profile
        """
        profile = OrderedCreatorRecord.objects.filter(
            creator__profile__isnull=False)[:1].get().creator.profile
        entries = [
            UserProfileEntriesSerializer.serialize_entry(ocr.entry)
            for ocr in OrderedCreatorRecord.objects.filter(
                creator__profile=profile)
        ]

        response = self.client.get('{url}?created'.format(
            url=reverse('profile-entries', kwargs={'pk': profile.id})))
        profile_json = json.loads(str(response.content, 'utf-8'))
        self.assertListEqual(profile_json['created'], entries)
Пример #2
0
    def test_profile_entries_published(self):
        """
        Get the published entries for a profile
        """
        profile = UserProfile.objects.filter(
            related_user__entries__isnull=False)[:1].get()
        entries = [
            UserProfileEntriesSerializer.serialize_entry(entry)
            for entry in Entry.objects.public().filter(
                published_by=profile.user)
        ]

        response = self.client.get('{url}?published'.format(
            url=reverse('profile-entries', kwargs={'pk': profile.id})))
        profile_json = json.loads(str(response.content, 'utf-8'))
        self.assertListEqual(profile_json['published'], entries)
Пример #3
0
    def test_profile_entries_favorited(self):
        """
        Get the favorited entries for a profile
        """
        profile = self.user.profile
        entries = Entry.objects.public()[:2]
        serialized_entries = []

        for entry in entries:
            self.client.put(reverse('bookmark', kwargs={'entryid': entry.id}))
            serialized_entries.append(
                UserProfileEntriesSerializer.serialize_entry(entry))

        response = self.client.get('{url}?favorited'.format(
            url=reverse('profile-entries', kwargs={'pk': profile.id})))
        profile_json = json.loads(str(response.content, 'utf-8'))
        self.assertListEqual(profile_json['favorited'], serialized_entries)