Пример #1
0
 def test_one_tvl(self):
     team, new_team_video = self._create_new_team_video()
     reset_solr()
     self._set_my_languages('ko')
     url = reverse("teams:detail", kwargs={"slug": team.slug})
     response = self.client.get(url)
     self.assertEqual(1, len(response.context['team_video_md_list']))
Пример #2
0
    def test_detail_contents_after_edit(self):
        # make sure edits show up in search result from solr
        self.client.login(**self.auth)
        team = Team.objects.get(pk=1)
        tv = team.teamvideo_set.get(pk=1)
        tv.title = ''
        tv.description = ''
        tv.save()
        data = {
            "languages-MAX_NUM_FORMS": u"",
            "languages-INITIAL_FORMS": u"0",
            "title": u"change title",
            "languages-0-language": u"el",
            "languages-0-id": u"",
            "languages-TOTAL_FORMS": u"1",
            "languages-0-completed": u"on",
            "thumbnail": u"",
            "description": u"and descriptionnn",
            "project": team.default_project.pk,

        }
        url = reverse("teams:team_video", kwargs={"team_video_pk": tv.pk})
        response = self.client.post(url, data)
        self.assertRedirects(response, reverse("teams:team_video", kwargs={"team_video_pk": tv.pk}))

        reset_solr()

        tv = team.teamvideo_set.get(pk=1)
        team_video_search_records = self._tv_search_record_list(team)

        for tv in team_video_search_records:
            if tv.title == 'change title':
                break
        self.assertEquals('and descriptionnn', tv.description)
Пример #3
0
 def test_one_tvl(self):
     team, new_team_video = self._create_new_team_video()
     reset_solr()
     self._set_my_languages('ko')
     url = reverse("teams:detail", kwargs={"slug": team.slug})
     response = self.client.get(url)
     self.assertEqual(1, len(response.context['team_video_md_list']))
Пример #4
0
    def test_detail_contents_unrelated_video(self):
        from videos.models import SubtitleLanguage

        team, new_team_video = self._create_new_team_video()
        en = SubtitleLanguage(video=new_team_video.video, language='en')
        en.is_original = True
        en.is_complete = True
        en.save()
        self._set_my_languages('en', 'ru')
        # now add a Russian video with no subtitles.
        self._add_team_video(
            team, u'ru',
            u'http://upload.wikimedia.org/wikipedia/commons/6/61/CollateralMurder.ogv')

        reset_solr()

        team = Team.objects.get(id=team.id)

        self.assertEqual(2, team.teamvideo_set.count())

        # both videos should be in the list
        search_record_list = self._tv_search_record_list(team)
        self.assertEqual(2, len(search_record_list))

        # but the one with en subs should be second, since it was added earlier
        self.assertEqual('en', search_record_list[1].original_language)
Пример #5
0
 def setUp(self):
     self.auth = {
         "username": u"admin",
         "password": u"admin"
     }
     self.user = User.objects.get(username=self.auth["username"])
     reset_solr()
Пример #6
0
        def test_right_team_filter(self):
            """
            This is a test for story : #https://www.pivotaltracker.com/story/show/16450237
            We add a video for moderation, create versions. Check we have the right number
            of videos to moderate on that dashboard.
            We then put antother video for another team under moderation. Then we check that each
            team's dashboard will only show it's own video on the dashboard.
            """
            from haystack.query import SearchQuerySet
            from apps.teams.moderation_views import _get_moderation_results


            team1 = self.team
            other_user  = User.objects.exclude(teammember__in=[x for x in team1.members.all()]).exclude(pk=self.user.pk)[0]
            self.assertEquals(team1.get_pending_moderation().count() , 0)
            tv1 = team1.teamvideo_set.all()[0]

            add_moderation(tv1.video, team1, self.user)
            self.assertEquals(team1.get_pending_moderation().count() , 0)

            self._create_versions( tv1.video.subtitle_language(), num_versions=2, user=other_user)
            _update_search_index(tv1.video)
            self.assertEquals(self.team.get_pending_moderation().count(), 2)


            form, results = _get_moderation_results(RequestMockup(self.user), tv1.team)
            team_video_pks = [x.team_video_pk for x in results]
            check_pks = [x.pk for x in team1.teamvideo_set.all()]

            for pk in team_video_pks:
                self.assertTrue(pk in check_pks)
            # second team should be filteres
            team2 = Team.objects.exclude(pk=team1.pk)[0]
            tv2 = team2.teamvideo_set.exclude(video=tv1.video)[0]
            lang, c  = SubtitleLanguage.objects.get_or_create(video=tv2.video, is_original=False, language="pt")
            member = TeamMember(user=self.user, team=team2, role=TeamMember.ROLE_MANAGER)
            member.save()
            add_moderation(tv2.video, team2, self.user)
            self.assertEquals(tv2.video.moderated_by , team2)
            other_user  = User.objects.exclude(teammember__in=[x for x in team2.members.all()]).exclude(pk=self.user.pk)[0]
            self.assertFalse(tv1.team == tv2.team)
            self.assertFalse(tv1.video == tv2.video)
            self.assertEquals(team2.get_pending_moderation().count() , 0)
            num_versions = 2
            versions = self._create_versions( lang, num_versions=num_versions, user=other_user)
            _update_search_index(tv2.video)
            self.assertEquals(team2.get_pending_moderation().count(), num_versions)
            versions =  team2.get_pending_moderation()
            videos_with_new = set()
            [videos_with_new.add(v.video) for v in versions]

            form, results = _get_moderation_results(RequestMockup(self.user), tv2.team)
            team_video_pks = [x.team_video_pk for x in results]
            check_pks = [x.pk for x in team2.teamvideo_set.all()]
            for pk in team_video_pks:
                self.assertTrue(pk in check_pks)
            self.assertEquals(results.count(), 1)
            self.assertEquals(results.count() , len(videos_with_new))
            reset_solr()
Пример #7
0
 def setUp(self):
     fix_teams_roles()
     self.auth = {
         "username": u"admin",
         "password": u"admin"
     }
     self.user = User.objects.get(username=self.auth["username"])
     reset_solr()
Пример #8
0
    def test_detail_contents(self):
        team, new_team_video = self._create_new_team_video()

        reset_solr()

        # The video should be in the list.
        record_list = self._tv_search_record_list(team)
        self.assertEqual(1, len(record_list))
        self.assertEqual(new_team_video.video.video_id, record_list[0].video_id)
Пример #9
0
    def test_detail_contents(self):
        team, new_team_video = self._create_new_team_video()
        self.assertEqual(1, new_team_video.video.subtitlelanguage_set.count())

        reset_solr()

        # The video should be in the list. 
        record_list = self._tv_search_record_list(team)
        self.assertEqual(1, len(record_list))
        self.assertEqual(new_team_video.video.video_id, record_list[0].video_id)
Пример #10
0
    def test_hidden_video_no_solr(self):
        reset_solr()
        self.assertTrue(self._in_solr(self.video))

        policy = VideoVisibilityPolicy.objects.create_for_video(
            self.video,
            VideoVisibilityPolicy.SITE_VISIBILITY_PRIVATE_OWNER,
            self.team1,
            VideoVisibilityPolicy.WIDGET_VISIBILITY_HIDDEN,
        )
        policy.save()
        self.video = refresh(self.video)
        reset_solr()
        self.assertFalse(self._in_solr(self.video))
Пример #11
0
    def setUp(self):
        self.auth = {
            "username": u"admin",
            "password": u"admin"
        }    
        self.user = User.objects.get(username=self.auth["username"])

        self.client.login(**self.auth)
        from apps.testhelpers.views import _create_videos, _create_team_videos
        fixture_path = os.path.join(settings.PROJECT_ROOT, "apps", "videos", "fixtures", "teams-list.json")
        data = json.load(open(fixture_path))
        self.videos = _create_videos(data, [self.user])
        self.team, created = Team.objects.get_or_create(name="test-team", slug="test-team")
        self.tvs = _create_team_videos( self.team, self.videos, [self.user])
        reset_solr()
Пример #12
0
    def setUp(self):
        fix_teams_roles()
        self.auth = {
            "username": u"admin",
            "password": u"admin"
        }
        self.user = User.objects.get(username=self.auth["username"])

        self.client.login(**self.auth)
        from apps.testhelpers.views import _create_videos, _create_team_videos
        fixture_path = os.path.join(settings.PROJECT_ROOT, "apps", "videos", "fixtures", "teams-list.json")
        data = json.load(open(fixture_path))
        self.videos = _create_videos(data, [self.user])
        self.team, created = Team.objects.get_or_create(name="test-team", slug="test-team")
        self.tvs = _create_team_videos( self.team, self.videos, [self.user])
        reset_solr()
Пример #13
0
    def test_no_dupes_without_buttons(self):
        team, new_team_video = self._create_new_team_video()
        self._set_my_languages('ko', 'en')

        self.client.post(
            reverse('videos:upload_subtitles'),
            self._make_data(new_team_video.video.id, 'en'))

        self.client.post(
            reverse('videos:upload_subtitles'),
            self._make_data(new_team_video.video.id, 'es'))

        reset_solr()

        url = reverse("teams:detail", kwargs={"slug": team.slug})
        response = self.client.get(url)
        self.assertEqual(1, len(response.context['team_video_md_list']))
Пример #14
0
    def test_detail_contents_original_subs(self):
        team, new_team_video = self._create_new_team_video()

        # upload some subs to the new video. make sure it still appears.
        data = self._make_data(new_team_video.video.id, 'en')
        response = self.client.post(reverse('videos:upload_subtitles'), data)

        reset_solr()

        url = reverse("teams:detail", kwargs={"slug": team.slug})
        response = self.client.get(url)

        # The video should be in the list.
        self.assertEqual(1, len(response.context['team_video_md_list']))

        # but we should see no "no work" message
        self.assertTrue('allow_noone_language' not in response.context or \
                            not response.context['allow_noone_language'])
Пример #15
0
    def test_complete_contents(self):
        request = RequestMockup(User.objects.all()[0])
        create_two_sub_session(request, completed=True)

        team, new_team_video = self._create_new_team_video()
        en = new_team_video.video.subtitle_language()
        en.is_complete = True
        en.save()
        video = Video.objects.get(id=en.video.id)
        self.assertEqual(True, video.is_complete)

        reset_solr()

        search_record_list = self._complete_search_record_list(team)
        self.assertEqual(1, len(search_record_list))
        search_record = search_record_list[0]
        self.assertEqual(1, len(search_record.video_completed_langs))
        self.assertEqual('en', search_record.video_completed_langs[0])
Пример #16
0
    def test_detail_contents_original_subs(self):
        team, new_team_video = self._create_new_team_video()

        # upload some subs to the new video. make sure it still appears.
        data = self._make_data(new_team_video.video.id, 'en')
        response = self.client.post(reverse('videos:upload_subtitles'), data)

        reset_solr()

        url = reverse("teams:detail", kwargs={"slug": team.slug})
        response = self.client.get(url)

        # The video should be in the list.
        self.assertEqual(1, len(response.context['team_video_md_list']))

        # but we should see no "no work" message
        self.assertTrue('allow_noone_language' not in response.context or \
                            not response.context['allow_noone_language'])
Пример #17
0
    def test_visibility_when_owned_by_user(self):
        tv, created = TeamVideo.objects.get_or_create(video=self.video,
                                                      team=self.team1)
        tv.added_by = self.team1_member.user
        reset_solr()
        self.assertTrue(self._tv_in_solr(tv, self.regular_user))

        policy = VideoVisibilityPolicy.objects.create_for_video(
            self.video,
            VideoVisibilityPolicy.SITE_VISIBILITY_PRIVATE_OWNER,
            self.regular_user,
            VideoVisibilityPolicy.WIDGET_VISIBILITY_HIDDEN,
        )
        policy.save()
        self.video = refresh(self.video)
        self.assertFalse(self._tv_in_solr(tv, self.team1_member.user))
        self.assertFalse(self._tv_in_solr(tv, self.team2_member.user))
        self.assertFalse(self._tv_in_solr(tv, self.regular_user))
Пример #18
0
    def test_complete_contents(self):
        request = RequestMockup(User.objects.all()[0])
        create_two_sub_session(request, completed=True)

        team, new_team_video = self._create_new_team_video()
        en = new_team_video.video.subtitle_language()
        en.is_complete = True
        en.save()
        video = Video.objects.get(id=en.video.id)
        self.assertEqual(True, video.is_complete)

        # We have to update the metadata here to make sure the video is marked
        # as complete for Solr.
        metadata_manager.update_metadata(video.pk)

        reset_solr()

        search_record_list = self._complete_search_record_list(team)
        self.assertEqual(1, len(search_record_list))
        search_record = search_record_list[0]
        self.assertEqual(1, len(search_record.video_completed_langs))
        self.assertEqual('en', search_record.video_completed_langs[0])
Пример #19
0
 def test_remove_moderation(self):
     reset_solr()
     add_moderation(self.video, self.team, self.user)
     lang = self.video.subtitle_language()
     [ self._make_subs(lang, 5) for x in xrange(0, 1)]
     self.assertEquals(self.team.get_pending_moderation().count(), 1)
     version = self.team.get_pending_moderation()[0]
     approve_version(version, self.team, self.user)
     self.assertEquals(self.team.get_pending_moderation().count(), 0)
     self._login(is_moderator=True)
     # dashboard should have no video to moderate
     form, results = _get_moderation_results(RequestMockup(self.user), self.team)
     self.assertEquals(0, results.count())        
     url = reverse("moderation:revision-remove-moderation", kwargs={"team_id":self.team.pk, "version_id":version.pk})
     response = self.client.post(url, {}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
     data = json.loads(response.content)
     self.assertEquals(response.status_code, 200)
     self.assertEquals(True, data["success"])
     self.assertEquals(self.team.get_pending_moderation().count(), 1)
     # dashboard should have one video to moderate
     form, results = _get_moderation_results(RequestMockup(self.user), self.team)
     self.assertEquals(1, results.count())
     reset_solr()
Пример #20
0
    def test_detail_contents_unrelated_video(self):
        team, new_team_video = self._create_new_team_video()
        en = new_team_video.video.subtitle_language()
        en.is_complete = True
        en.save()
        self._set_my_languages('en', 'ru')
        # now add a Russian video with no subtitles.
        self._add_team_video(
            team, u'ru',
            u'http://upload.wikimedia.org/wikipedia/commons/6/61/CollateralMurder.ogv')

        reset_solr()

        team = Team.objects.get(id=team.id)

        self.assertEqual(2, team.teamvideo_set.count())

        # both videos should be in the list
        search_record_list = self._tv_search_record_list(team)
        self.assertEqual(2, len(search_record_list))

        # but the one with en subs should be first, since we can translate it into russian.
        self.assertEqual('en', search_record_list[0].original_language)
Пример #21
0
 def setUp(self):
     super(TestDashboard, self).setUp()
     reset_solr()