def setUpClass(cls): super(TestCaseProjectsFilter, cls).setUpClass() management.call_command('flush', interactive=False) cls.data_utils = data_helpers.DataHelpers() cls.videos_tab = videos_tab.VideosTab(cls) cls.team_owner = UserFactory.create() cls.logger.info('setup: Creating team Video Test') cls.team = TeamMemberFactory.create(user=cls.team_owner).team cls.manager_user = TeamMemberFactory(role="ROLE_ADMIN", team=cls.team, user=UserFactory()).user cls.logger.info('setup: Adding project one and project two with ' 'workflows enabled') cls.project1 = TeamProjectFactory.create( team=cls.team, workflow_enabled=True, ) cls.project2 = TeamProjectFactory.create(team=cls.team, workflow_enabled=True) data = json.load(open('apps/videos/fixtures/teams-list.json')) videos = _create_videos(data, []) for video in videos: TeamVideoFactory.create(team=cls.team, video=video, added_by=cls.manager_user, project=cls.project2) management.call_command('update_index', interactive=False) cls.videos_tab.open_videos_tab(cls.team.slug) cls.videos_tab.log_in(cls.manager_user.username, 'password')
def setUpClass(cls): super(TestCaseAddRemoveEdit, cls).setUpClass() cls.data_utils = data_helpers.DataHelpers() cls.logger.info("Create team and add 1 video") cls.team_owner = UserFactory.create() cls.team = TeamMemberFactory.create(user=cls.team_owner).team cls.manager_user = TeamMemberFactory( role="ROLE_ADMIN", team=cls.team, user=UserFactory(username='******')).user cls.videos_tab = videos_tab.VideosTab(cls) data = { 'url': 'http://www.youtube.com/watch?v=WqJineyEszo', 'video__title': ('X Factor Audition - Stop Looking At My ' 'Mom Rap - Brian Bradley'), 'type': 'Y' } cls.test_video = cls.data_utils.create_video(**data) cls.data_utils.add_subs(video=cls.test_video) TeamVideoFactory.create(team=cls.team, video=cls.test_video, added_by=cls.manager_user) management.call_command('update_index', interactive=False) cls.videos_tab.open_videos_tab(cls.team.slug)
def test_video_list(self): """List the available videos that are in teams. GET /api2/partners/videos/ video_url team project order_by title: ascending -title: descending created: older videos first -created : newer videos """ tv = self.data_utils.create_video() TeamVideoFactory.create(team=self.open_team, video=tv, added_by=self.user) for x in range(5): TeamVideoFactory.create(team=self.open_team, added_by=self.user, project=self.project1) url_part = 'videos/' r = self.data_utils.make_request(self.user, 'get', url_part) response = r.json video_objects = response['objects'] videos_list = [] for k, v in itertools.groupby(video_objects, operator.itemgetter('id')): videos_list.append(k) self.assertIn(tv.video_id, videos_list)
def test_remove_team_only(self): """Remove video from team but NOT site. Must be the team owner to get the team vs. site dialog. """ self.videos_tab.log_in(self.team_owner.username, 'password') tv = VideoUrlFactory(video__title='team only annihilation').video TeamVideoFactory.create(team=self.team, video=tv, added_by=self.manager_user) management.call_command('update_index', interactive=False) #Search for the video in team videos and remove it. self.videos_tab.open_videos_tab(self.team.slug) self.videos_tab.search(tv.title) self.videos_tab.remove_video(video=tv.title, removal_action='team-removal') time.sleep(2) #Update the solr index management.call_command('update_index', interactive=False) #Verify video no longer in teams self.assertEqual(tv.get_team_video(), None) self.videos_tab.search(tv.title) self.assertEqual(self.videos_tab.NO_VIDEOS_TEXT, self.videos_tab.search_no_result()) #Verify video is present on the site watch_pg = watch_page.WatchPage(self) watch_pg.open_watch_page() results_pg = watch_pg.basic_search(tv.title) self.assertTrue(results_pg.search_has_results())
def test_query_project(self): """List the available videos. GET /api2/partners/videos/ video_url team project order_by title: ascending -title: descending created: older videos first -created : newer videos """ for x in range(5): TeamVideoFactory.create(team=self.open_team, added_by=self.user, project=self.project1) url_part = 'videos/?project=%s' % self.project1.slug r = self.data_utils.make_request(self.user, 'get', url_part) response = r.json video_objects = response['objects'] videos_list = [] for k, v in itertools.groupby(video_objects, operator.itemgetter('id')): videos_list.append(k) self.assertEqual(5, len(videos_list))
def setUpClass(cls): super(TestCaseFilterSort, cls).setUpClass() #management.call_command('flush', interactive=False) cls.data_utils = data_helpers.DataHelpers() cls.logger.info("Create team 'video-test' and add 1 video") cls.team_owner = UserFactory.create(is_partner=True) cls.team = TeamMemberFactory.create(user=cls.team_owner).team cls.manager_user = TeamMemberFactory(role="ROLE_ADMIN", team=cls.team, user=UserFactory()).user cls.videos_tab = videos_tab.VideosTab(cls) vidurl_data = { 'url': 'http://www.youtube.com/watch?v=WqJineyEszo', 'video__title': 'X Factor Audition - Stop Looking At My Mom Rap', 'type': 'Y' } cls.test_video = cls.data_utils.create_video(**vidurl_data) cls.data_utils.add_subs(video=cls.test_video) TeamVideoFactory.create(team=cls.team, video=cls.test_video, added_by=cls.manager_user) videos = cls.data_utils.create_several_team_videos_with_subs( cls.team, cls.manager_user) management.call_command('update_index', interactive=False)
def test_remove_site(self): """Remove video from team and site, total destruction! Must be the team owner to get the team vs. site dialog. """ self.videos_tab.log_in(self.team_owner.username, 'password') #Create a team video for removal. tv = VideoUrlFactory(video__title='total destruction').video TeamVideoFactory.create(team=self.team, video=tv, added_by=self.manager_user) management.call_command('update_index', interactive=False) #Search for the video in team videos and remove it. self.videos_tab.open_videos_tab(self.team.slug) self.videos_tab.search(tv.title) self.videos_tab.remove_video(video=tv.title, removal_action='total-destruction') #Verify video no longer in teams self.videos_tab.search(tv.title) self.assertEqual(self.videos_tab.NO_VIDEOS_TEXT, self.videos_tab.search_no_result()) self.videos_tab.open_videos_tab(self.team.slug) #Verify video no longer on site watch_pg = watch_page.WatchPage(self) watch_pg.open_watch_page() self.logger.info('searching for the test video %s' % tv.title) results_pg = watch_pg.basic_search(tv.title) self.assertTrue(results_pg.search_has_no_results())
def setUpClass(cls): super(TestCaseTeamsPage, cls).setUpClass() management.call_command('flush', interactive=False) cls.COOL_TEAM_NAME = "A1 Waay Cool team" #CREATE A USER cls.cool_user = UserFactory.create(username='******', password='******') cls.logger.info("creating some teams for testing") #create 5 open teams for x in range(5): TeamMemberFactory.create( team__name='my team ' + str(x), team__slug='my-team-' + str(x), ) #create an open team with description text and 2 members cls.team = TeamMemberFactory.create( team__name="A1 Waay Cool team", team__slug='a1-waay-cool-team', team__description='this is the coolest, most creative team ever', ).team TeamMemberFactory.create(team=cls.team, user=cls.cool_user) TeamVideoFactory.create(team=cls.team, added_by=cls.cool_user) #create an application team with 3 members and 5 videos cls.app_team = TeamMemberFactory.create( team__name='the application-only team', team__slug='the-application-only-team', team__membership_policy=1, ).team TeamMemberFactory.create(team=cls.app_team, user=UserFactory.create()) TeamMemberFactory.create(team=cls.app_team, user=cls.cool_user) for x in range(5): TeamVideoFactory.create(team=cls.app_team, added_by=cls.cool_user) #create 1 private invitation team cls.priv_team = TeamMemberFactory.create( team__name='my own private idaho ', team__slug='private-idaho', team__membership_policy=2, team__is_visible=False, ).team #create 1 private application team cls.priv_team = TeamMemberFactory.create( team__name='private application', team__slug='private-application', team__membership_policy=1, team__is_visible=False, ).team cls.teams_dir_pg = TeamsDirPage(cls) cls.a_team_pg = ATeamPage(cls)
def test_pagination_admin(self): """Check number of videos displayed per page for team admin. """ for x in range(50): TeamVideoFactory.create(team=self.limited_access_team, video=VideoFactory.create(), added_by=self.team_owner) management.call_command('update_index', interactive=False) self.videos_tab.log_in(self.team_owner.username, 'password') self.videos_tab.open_videos_tab(self.limited_access_team.slug) self.assertEqual(8, self.videos_tab.num_videos())
def create_several_team_videos_with_subs(self, team, teamowner, data=None): """Uses the helper data from the apps.videos.fixtures to create data. The test vidoes are then assigned to the specified team. Returns the list of video. """ if not data: testdata = simplejson.load( open('apps/videos/fixtures/teams-list.json')) else: testdata = simplejson.load(open(data)) videos = _create_videos(testdata, []) for video in videos: TeamVideoFactory.create(team=team, video=video, added_by=teamowner) return videos
def setUpClass(cls): super(TestCaseProjectsAddEdit, cls).setUpClass() management.call_command('flush', interactive=False) cls.data_utils = data_helpers.DataHelpers() cls.videos_tab = videos_tab.VideosTab(cls) cls.team_owner = UserFactory.create() cls.logger.info('setup: Creating team Video Test') cls.team = TeamMemberFactory.create(user=cls.team_owner).team cls.logger.info('setup: Adding a team with 2 projects.') cls.project1 = TeamProjectFactory.create(team=cls.team) cls.project2 = TeamProjectFactory.create(team=cls.team) test_videos = [ 'jaws.mp4', 'Birds_short.oggtheora.ogg', 'fireplace.mp4' ] cls.videos_list = [] for vid in test_videos: video_url = 'http://qa.pculture.org/amara_tests/%s' % vid[0] tv = VideoUrlFactory(url=video_url, video__title=vid).video v = TeamVideoFactory(video=tv, team=cls.team, added_by=cls.team_owner, project=cls.project2).video cls.videos_list.append(v) management.call_command('update_index', interactive=False) cls.videos_tab.open_videos_tab(cls.team.slug) cls.videos_tab.log_in(cls.team_owner.username, 'password') cls.project1_page = ('teams/{0}/videos/?project={1}'.format( cls.team.slug, cls.project1.slug)) cls.project2_page = ('teams/{0}/videos/?project={1}'.format( cls.team.slug, cls.project2.slug))
def test_update_speaker_metatdata(self): """Update video metadata, add speaker name field PUT /api2/partners/videos/[video-id]/ """ tv = self.data_utils.create_video() TeamVideoFactory(team=self.open_team, added_by=self.user, video=tv) vid_id = tv.video_id url_part = 'videos/%s/' % vid_id new_data = { 'title': 'MVC webM output sample', 'description': ('This is a sample vid converted to webM ' '720p using Miro Video Converter'), 'metadata': { 'speaker-name': 'Santa', 'location': 'North Pole' } } r = self.data_utils.make_request(self.user, 'put', url_part, **new_data) response = r.json self.video_pg.open_video_page(vid_id) #Check response metadata for k, v in new_data.iteritems(): self.assertEqual(v, response[k]) #Check video displays on the site self.assertIn(new_data['metadata']['speaker-name'], self.video_pg.speaker_name())
def test_query__team(self): """List the available videos. GET /api2/partners/videos/team=<team slug> """ for x in range(5): TeamVideoFactory.create(team=self.open_team, added_by=self.user, project=self.project1) url_part = 'videos/?team=%s' % self.open_team.slug status, response = self.data_utils.api_get_request(self.user, url_part) video_objects = response['objects'] videos_list = [] for k, v in itertools.groupby(video_objects, operator.itemgetter('id')): videos_list.append(k) self.assertEqual(5, len(videos_list))
def test_sort_most_subtitles(self): """Sort on the project page by most subtitles. """ project_page = 'teams/{0}/videos/?project={1}'.format( self.team.slug, self.project2.slug) data2 = json.load( open('apps/webdriver_testing/check_teams/lots_of_subtitles.json')) videos2 = _create_videos(data2, []) for video in videos2: TeamVideoFactory.create(team=self.team, video=video, added_by=self.manager_user, project=self.project2) management.call_command('update_index', interactive=False) self.videos_tab.open_page(project_page) self.videos_tab.video_sort(sort_option='most subtitles') self.videos_tab.update_filters() self.videos_tab.videos_displayed() self.assertEqual(self.videos_tab.first_video_listed(), 'lots of translations')
def test_videos_added_daily(self): """check email sent with daily setting for videos added""" team2 = TeamMemberFactory(team__notify_interval='NOTIFY_DAILY').team mail.outbox = [] video = TeamVideoFactory.create( team=team2, video=self.data_utils.create_video()) tasks.add_videos_notification_daily.apply() msg = str(mail.outbox[-1].message()) self.logger.info(msg) self.assertIn('team has added new videos, and they need your help:', msg)
def setUpClass(cls): super(TestCaseSearch, cls).setUpClass() #management.call_command('flush', interactive=False) cls.data_utils = data_helpers.DataHelpers() cls.logger.info("Create team 'video-test' and add 1 video") cls.team_owner = UserFactory.create(is_partner=True) cls.team = TeamMemberFactory.create(user=cls.team_owner).team cls.manager_user = TeamMemberFactory(role="ROLE_ADMIN", team=cls.team, user=UserFactory()).user cls.videos_tab = videos_tab.VideosTab(cls) data = { 'url': 'http://www.youtube.com/watch?v=WqJineyEszo', 'video__title': ('X Factor Audition - Stop Looking At My ' 'Mom Rap - Brian Bradley'), 'type': 'Y' } cls.test_video = cls.data_utils.create_video(**data) subs_data = { 'language_code': 'en', 'subtitles': ('apps/webdriver_testing/subtitle_data/' 'Timed_text.en.srt'), 'complete': True, 'video': cls.test_video } cls.data_utils.add_subs(**subs_data) TeamVideoFactory.create(team=cls.team, video=cls.test_video, added_by=cls.manager_user) management.call_command('update_index', interactive=False)
def test_sort__title(self): """List the available videos sorted by title (desc) GET /api2/partners/videos/ """ for x in range(3): TeamVideoFactory.create(team=self.open_team, added_by=self.user, project=self.project1) TeamVideoFactory.create(team=self.open_team, added_by=self.user, project=self.project1, video__title='Zzz-test-video') url_part = 'videos/?order_by=-title' status, response = self.data_utils.api_get_request(self.user, url_part) video_objects = response['objects'] videos_list = [] for k, v in itertools.groupby(video_objects, operator.itemgetter('title')): videos_list.append(k) self.assertEqual('Zzz-test-video', videos_list[0])
def create_tv_with_original_subs(cls, lc, user, team, complete=True): sub_file = 'apps/webdriver_testing/subtitle_data/Timed_text.en.srt' video = cls.data_utils.create_video() tv = TeamVideoFactory.create(team=team, video=video, added_by=user) data = { 'language_code': lc, 'complete': complete, 'visibility': 'private', 'committer': user, 'video': video } cls.data_utils.add_subs(**data) return video, tv
def create_tv_with_original_subs(cls, lc, user, team, complete=True): sub_file = 'apps/webdriver_testing/subtitle_data/Timed_text.en.srt' video = VideoUrlFactory().video tv = TeamVideoFactory.create( team=team, video=video, added_by=user) data = {'language_code': lc, 'video': video.pk, 'primary_audio_language_code': lc, 'draft': open(sub_file), 'is_complete': complete, 'complete': int(complete), } cls.data_utils.upload_subs(user, **data) return video, tv
def test_videos_added_hourly(self): """check emails sent with hourly setting for videos added""" TeamMemberFactory(role="ROLE_CONTRIBUTOR", user=UserFactory(), team=self.team) for x in range(0,5): video = TeamVideoFactory.create( team=self.team, video=self.data_utils.create_video()) mail.outbox = [] tasks.add_videos_notification_hourly.apply() msg = str(mail.outbox[-1].message()) self.assertIn('team has added new videos, and they need your help:', msg) for x in mail.outbox: self.logger.info(x.message()) self.assertEqual(3,len(mail.outbox))
def test_delete_button_non_workflow_team(self): """Non workflow team videos have Delete Subtitle Language button. """ video = self.data_utils.create_video() tv = TeamVideoFactory(team=self.basic_team, added_by=self.owner, video=video) self._upload_subtitles(video, 'en', self.rev1, self.contributor) staff = UserFactory.create(is_staff=True) self.video_lang_pg.log_in(self.owner.username, 'password') self.video_lang_pg.open_video_lang_page(video.video_id, 'en') self.assertTrue(self.video_lang_pg.delete_subtitles_language_exists()) video, tv = self._add_team_video() self._upload_subtitles(self.video, 'en', self.rev1, self.contributor)
def setUpClass(cls): super(TestCaseDraftVideos, cls).setUpClass() cls.data_utils = data_helpers.DataHelpers() cls.video_pg = video_page.VideoPage(cls) cls.video_lang_pg = video_language_page.VideoLanguagePage(cls) cls.menu = unisubs_menu.UnisubsMenu(cls) cls.create_modal = dialogs.CreateLanguageSelection(cls) cls.user = UserFactory(username='******', is_partner=True) #Add a team with workflows, tasks and preferred languages cls.logger.info('setup: Create a team with tasks enabled') cls.team = TeamMemberFactory.create( team__workflow_enabled=True, team__subtitle_policy=20, team__translate_policy=20, user=cls.user, ).team cls.team_workflow = WorkflowFactory( team=cls.team, autocreate_subtitle=True, autocreate_translate=True, approve_allowed=10, review_allowed=10, ) cls.member = TeamMemberFactory.create( role="ROLE_CONTRIBUTOR", team=cls.team, user=UserFactory(username='******')).user cls.nonmember = UserFactory() #Add video to team with draft subtitles cls.logger.info('Setup: Add video to team with draft subs.') cls.draft = TeamVideoFactory.create( team=cls.team, video=cls.data_utils.create_video(), added_by=cls.user).video data = { 'visibility': 'private', 'video': cls.draft, 'committer': cls.user } cls.data_utils.add_subs(**data) cls.video_pg.open_video_page(cls.draft.video_id)
def _create_tv_with_original_subs(cls, user, team, complete=True): vid_data = {'video__primary_audio_language_code': 'en' } video = cls.data_utils.create_video(**vid_data) tv = TeamVideoFactory.create( team=team, video=video, added_by=user) data = { 'primary_audio_language_code': 'en', 'language_code': 'en', 'complete': int(complete), 'is_complete': complete, 'video': video.pk, 'draft': open('apps/webdriver_testing/subtitle_data/Timed_text.en.srt') } cls.data_utils.upload_subs(user, **data) cls.logger.info(video.subtitle_language('en')) return video, tv
def setUpClass(cls): super(TestCaseModeratedSubtitlesUpload, cls).setUpClass() cls.data_utils = data_helpers.DataHelpers() cls.user = UserFactory.create(username='******') cls.data_utils.create_user_api_key(cls.user) #Create some test data and set subtitle data dir cls.test_video = cls.data_utils.create_video() cls.subs_data_dir = os.path.join(os.getcwd(), 'apps', 'webdriver_testing', 'subtitle_data') # self.team_video already has a set of subtitles. # Create a team with moderation settings cls.my_team = TeamMemberFactory.create( team__name='Video Test', team__slug='video-test', user=cls.user, team__is_moderated=True, team__workflow_enabled=True, ).team # Set the team workflow to peer review required. workflow = WorkflowFactory(team=cls.my_team) workflow.review_allowed = 10 workflow.save() # Add test_video to the team and create a transcription task. cls.lang_code = 'en' cls.tv = TeamVideoFactory.create(team=cls.my_team, video=cls.test_video, added_by=cls.user) subtitle_lang = cls.test_video.subtitle_language(cls.lang_code) task = TaskFactory(type=10, team=cls.my_team, team_video=cls.tv, language=cls.lang_code) cls.video_language_pg = video_language_page.VideoLanguagePage(cls) cls.tasks_pg = tasks_tab.TasksTab(cls)
def test_sort__newest(self): """List the available videos. GET /api2/partners/videos/ """ team_vid_list = [] for x in range(3): vid = TeamVideoFactory.create(team=self.open_team, added_by=self.user, project=self.project1).video team_vid_list.append(vid.title) time.sleep(1) url_part = 'videos/?order_by=-created' status, response = self.data_utils.api_get_request(self.user, url_part) video_objects = response['objects'] videos_list = [] for k, v in itertools.groupby(video_objects, operator.itemgetter('title')): videos_list.append(k) self.assertEqual(team_vid_list[-1], videos_list[0])
def _add_team_video(cls): video = cls.data_utils.create_video() tv = TeamVideoFactory(team=cls.team, added_by=cls.owner, video=video) return video, tv