def test_profiles_followers_search(self): self.c.login(username=self.user01.username, password='******') found_friend_user, found_friend_userp = create_user_with_profile( '*****@*****.**', first_name="Found Friend", last_name="User" ) self.user01p.friend_user(found_friend_user) found_follower_user, found_follower_userp = create_user_with_profile( '*****@*****.**', first_name="Found Follower", last_name="User" ) other_follower_user, other_follower_userp = create_user_with_profile( '*****@*****.**', first_name="Other Follower", last_name="User" ) found_follower_userp.follow_user(self.user01) other_follower_userp.follow_user(self.user01) response = self.search(name="Found", scope="profiles", scope_2="followers") self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data, { 'found_items_count': 1, 'found_items': [ { 'user': { 'uuid': found_follower_userp.uuid_str(), 'first_name': "Found Follower", 'last_name': "User", 'gender': "M", 'avatar': None }, 'status': { 'is_friend': False, 'is_follower': True, 'friendship_request_sent': False, 'is_followed': False, 'is_blocked': False, 'is_inbox_request': False, 'is_outbox_request': False } } ] })
def create_search_items(self): self.found_user, self.found_userp = create_user_with_profile( '*****@*****.**', first_name="Found", last_name="User" ) self.other_user, self.other_userp = create_user_with_profile( '*****@*****.**', first_name="Other", last_name="User" ) self.community_subject = CommunitySubject.objects.create( name="whatever", code="whatever" ) self.found_community = Community.objects.create( name="Found community", subject=self.community_subject, author=self.user01 ) self.other_community = Community.objects.create( name="Other community", subject=self.community_subject, author=self.user01 ) self.found_video_item = VideoItem.objects.create( author=self.user01, gallery=None, title="Found video", content_object=self.user01p, source="youtube", source_id="Youtube video", source_duration=43, source_cover_url='/home/rp/env/project/public/media/no_image.png', submitted=True ) self.other_video_item = VideoItem.objects.create( author=self.user01, gallery=None, title="Other video", content_object=self.user01p, source="youtube", source_id="Youtube video", source_duration=43, source_cover_url='/home/rp/env/project/public/media/no_image.png', submitted=True ) self.found_audio_item = AudioItem.objects.create( author=self.user01, gallery=None, title="Found audio", content_object=self.user01p, submitted=True ) self.other_audio_item = AudioItem.objects.create( author=self.user01, gallery=None, title="Other audio", content_object=self.user01p, submitted=True ) self.found_text_item = TextItem.objects.create( author=self.user01, gallery=None, title="Found text", content_object=self.user01p, submitted=True ) self.other_text_item = TextItem.objects.create( author=self.user01, gallery=None, title="Other text", content_object=self.user01p, submitted=True ) self.found_post = Post.objects.create( title="Found post", text="Found post text", author=self.user01, content_object=self.user01p ) self.other_post = Post.objects.create( title="Other post", text="Other post text", author=self.user01, content_object=self.user01p )
def setUp(self): self.c = APIClient() self.user01, self.user01p = create_user_with_profile('*****@*****.**')