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(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 setUpClass(cls): super(TestCaseTeamProjectResource, cls).setUpClass() cls.data_utils = data_helpers.DataHelpers() cls.user = UserFactory.create(username='******', is_partner=True) cls.team_owner = UserFactory.create(username='******') #create an open team with description text and 2 members cls.open_team = TeamMemberFactory.create( team__name="Cool team", team__slug='team-with-projects', team__description='this is the coolest, most creative team ever', user=cls.team_owner, ).team TeamMemberFactory(team=cls.open_team, role='ROLE_ADMIN', user=cls.user) #Open to the teams page so you can see what's there. cls.project1 = TeamProjectFactory( team=cls.open_team, name='team project one', slug='team-project-one', description='subtitle project number 1', guidelines='do a good job', workflow_enabled=False) cls.project2 = TeamProjectFactory(team=cls.open_team, name='team project two', workflow_enabled=True) cls.team_pg = ATeamPage(cls) cls.team_pg.open_team_page(cls.open_team.slug)
def create_workflow_team(cls): team = TeamMemberFactory.create(team__workflow_enabled=True, team__translate_policy=20, #any team team__subtitle_policy=20, #any team team__task_assign_policy=10, #any team user = cls.owner, ).team cls.workflow = WorkflowFactory(team = team, autocreate_subtitle=True, autocreate_translate=True, approve_allowed = 10, # manager review_allowed = 10, # peer ) lang_list = ['en', 'ru', 'pt-br', 'de', 'sv'] for language in lang_list: TeamLangPrefFactory.create(team=team, language_code=language, preferred=True) cls.contributor = TeamMemberFactory(role="ROLE_CONTRIBUTOR",team=team, user__first_name='Jerry', user__last_name='Garcia', user__pay_rate_code='L2').user cls.contributor2 = TeamMemberFactory(role="ROLE_CONTRIBUTOR", team=team, user__first_name='Gabriel José de la Concordia'.decode("utf-8"), user__last_name='García Márquez'.decode("utf-8")).user cls.admin = TeamMemberFactory(role="ROLE_ADMIN",team=team).user cls.manager = TeamMemberFactory(role="ROLE_MANAGER",team=team).user return team
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 setUpClass(cls): super(TestCaseTeamMessages, cls).setUpClass() cls.data_utils = data_helpers.DataHelpers() cls.a_team_pg = ATeamPage(cls) cls.members_tab = members_tab.MembersTab(cls) cls.messages_tab = messages_tab.MessagesTab(cls) cls.user_message_pg = user_messages_page.UserMessagesPage(cls) cls.non_member = UserFactory.create(username='******') cls.team_owner = UserFactory.create(is_partner = True) #CREATE AN APPLICATION-ONLY TEAM cls.team = TeamMemberFactory.create( team__membership_policy = 1, user = cls.team_owner, ).team cls.team_member = TeamMemberFactory.create(role="ROLE_CONTRIBUTOR", user=UserFactory(), team=cls.team).user #ADD THE TEST MESSAGES TO THE TEST TEAM cls.members_tab.open_members_page(cls.team.slug) cls.members_tab.log_in(cls.team_owner.username, 'password') cls.messages_tab.open_messages_tab(cls.team.slug) cls.messages_tab.edit_messages(cls._TEST_MESSAGES)
def test_directory__sort_by_newest(self): """sort teams list by newest. """ TeamMemberFactory.create(team__name='new team', team__slug='new-team', user=UserFactory.create()) self.teams_dir_pg.sort("date") self.assertEqual('new team', self.teams_dir_pg.first_team())
def setUpClass(cls): super(TestCaseVideoResource, cls).setUpClass() cls.user = UserFactory.create(username='******') cls.data_utils = data_helpers.DataHelpers() cls.test_video = cls.data_utils.create_video() cls.open_team = TeamMemberFactory.create( team__name="Cool team", team__slug='team-with-projects', team__description='this is the coolest, most creative team ever', user=cls.user, ).team cls.project1 = TeamProjectFactory( team=cls.open_team, name='team project one', slug='team-project-one', description='subtitle project number 1', guidelines='do a good job', workflow_enabled=False) cls.project2 = TeamProjectFactory(team=cls.open_team, name='team project two', workflow_enabled=True) cls.video_pg = video_page.VideoPage(cls) cls.watch_pg = watch_page.WatchPage(cls)
def test_download__multi_team_new(self): """Create a report for several teams. """ team2_user = UserFactory.create() team2 = TeamMemberFactory.create(user = team2_user).team video2, tv2 = self._create_tv_with_original_subs(team2_user, team2) self._upload_sv_translation(video2, team2_user, complete=True) for x in range(3): self._create_tv_with_original_subs(team2_user, team2) self.billing_pg.open_billing_page() self.billing_pg.log_in(self.terri.username, 'password') self.billing_pg.open_billing_page() start = (datetime.date.today() - datetime.timedelta(7)) end = (datetime.date.today() + datetime.timedelta(2)) self.logger.info(start.strftime("%Y-%m-%d")) team_names = ','.join([self.team.name, team2.name]) self.billing_pg.submit_billing_parameters(team_names, start.strftime("%Y-%m-%d"), end.strftime("%Y-%m-%d"), 'Crowd sourced') report_dl = self.billing_pg.check_latest_report_url() self.logger.info(report_dl) new_headers = ('Video Title,Video ID,Language,Minutes,Original,' 'Language number,Team,Created,Source,User') self.assertEqual(8, len(report_dl)) self.assertEqual(new_headers, report_dl[0])
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 setUpClass(cls): super(TestCaseAddFeeds, cls).setUpClass() cls.user = UserFactory.create() cls.team = TeamMemberFactory.create(user=cls.user).team cls.feed_pg = add_feed_page.AddFeedPage(cls) cls.feed_pg.open_feed_page(cls.team.slug) cls.feed_pg.log_in(cls.user.username, 'password')
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 test_manager_edit_permission(self): """Video policy: manager and admin; manager sees the edit link. """ vids = self.add_some_team_videos() self.logger.info('Adding manager user to the team and logging in') manager = TeamMemberFactory(role="ROLE_MANAGER", team=self.limited_access_team, user=UserFactory(username='******')).user self.videos_tab.log_in(manager.username, 'password') self.videos_tab.open_videos_tab(self.limited_access_team.slug) self.assertTrue(self.videos_tab.video_has_link(vids[0].title, 'Edit'))
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_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(TestCaseBilling, cls).setUpClass() cls.data_utils = data_helpers.DataHelpers() cls.billing_pg = billing_page.BillingPage(cls) cls.terri = UserFactory.create(username='******', is_staff=True, is_superuser=True) cls.user = UserFactory.create() cls.team = TeamMemberFactory.create(user = cls.user).team cls.video, cls.tv = cls._create_tv_with_original_subs(cls.user, cls.team) cls._upload_sv_translation(cls.video, cls.user, complete=True) cls.bill_dict = cls.create_team_bill() cls.billing_pg.open_billing_page() cls.billing_pg.log_in(cls.terri.username, 'password')
def setUpClass(cls): super(TestCaseTeamGuidelines, cls).setUpClass() cls.messages_tab = messages_tab.MessagesTab(cls) cls.tasks_tab = tasks_tab.TasksTab(cls) cls.team_owner = UserFactory.create() #CREATE AN OPEN TEAM WITH WORKFLOWS and AUTOTASKS cls.team = TeamMemberFactory.create(team__workflow_enabled=True, user=cls.team_owner).team #Turn on Task Autocreation WorkflowFactory.create(team=cls.team, autocreate_subtitle=True, autocreate_translate=True, review_allowed=10)
def test_add_team_duplicate(self): """Duplicate videos are not added again. """ dup_url = 'http://www.youtube.com/watch?v=WqJineyEszo' #Create a second team. team2 = TeamMemberFactory.create(user=self.manager_user).team #Open the new team and try to submit the video self.videos_tab.log_in(self.manager_user.username, 'password') self.videos_tab.open_videos_tab(team2.slug) self.videos_tab.add_video(dup_url) self.assertEqual(self.videos_tab.error_message(), 'This video already belongs to a team.')
def test_contributor_no_edit(self): """Video policy: manager and admin; contributor sees no edit link. """ vids = self.add_some_team_videos() self.logger.info('Adding user contributor to the team and logging in') #Create a user who is a contributor to the team. contributor = TeamMemberFactory( role="ROLE_CONTRIBUTOR", team=self.limited_access_team, user=UserFactory(username='******')).user self.videos_tab.log_in(contributor.username, 'password') self.videos_tab.open_videos_tab(self.limited_access_team.slug) self.assertFalse(self.videos_tab.video_has_link(vids[0].title, 'Edit'))
def test_restricted_manager_no_edit(self): """Video policy: manager and admin; language manager sees no edit link. """ vids = self.add_some_team_videos() self.logger.info('Adding English language manager and logging in') manager = TeamMemberFactory( role="ROLE_MANAGER", team=self.limited_access_team, user=UserFactory(username='******')) TeamManagerLanguageFactory(member=manager, language='en') self.videos_tab.log_in(manager.user.username, 'password') self.videos_tab.open_videos_tab(self.limited_access_team.slug) self.assertFalse(self.videos_tab.video_has_link(vids[0].title, 'Edit'))
def test_user(self): """User credit with subtitles is listed in the record. """ testuser = TeamMemberFactory.create().user video, tv = self._create_tv_with_original_subs(self.user, self.team) self._upload_sv_translation(video, testuser, complete=True) report = BillingFactory(start_date=(datetime.date.today() - datetime.timedelta(1)), end_date=datetime.datetime.now(), ) report.teams=[self.team] report.save() report.process() bill = 'user-data/%s' % report.csv_file bill_dict = self._bill_dict(bill) self.assertEqual(self.user.username, bill_dict[video.video_id]['en']['User']) self.assertEqual(testuser.username, bill_dict[video.video_id]['sv']['User'])
def test_admin_edit_link(self): """Video policy: admin only; admin sees edit link. """ self.logger.info('setup: Setting video policy to admin only') self.limited_access_team.video_policy = 3 self.limited_access_team.save() vids = self.add_some_team_videos() #Create a user who is a team admin. self.logger.info('Create a team admin and log in as that user') admin_member = TeamMemberFactory( role="ROLE_ADMIN", team=self.limited_access_team, user=UserFactory(username='******')).user self.videos_tab.log_in(admin_member.username, 'password') self.videos_tab.open_videos_tab(self.limited_access_team.slug) self.assertTrue(self.videos_tab.video_has_link(vids[0].title, 'Edit'))
def test_manager_no_tasks(self): """Task policy: admin only; manager sees no task link. """ self.browser.delete_all_cookies() self.logger.info('setup: Setting task policy to admin only') self.limited_access_team.task_assign_policy = 30 self.limited_access_team.save() vids = self.add_some_team_videos() self.logger.info('Adding manager user to the team and logging in') #Create a user who is a manager to the team. manager = TeamMemberFactory(role="ROLE_MANAGER", team=self.limited_access_team, user=UserFactory(username='******')).user self.videos_tab.log_in(manager.username, 'password') self.videos_tab.open_videos_tab(self.limited_access_team.slug) self.assertFalse(self.videos_tab.video_has_link( vids[0].title, 'Tasks'))
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_restricted_manager_edit(self): """Video policy: all team members; language manager sees edit link. """ self.logger.info('setup: Setting video policy to all team members') self.limited_access_team.video_policy = 1 self.limited_access_team.save() vids = self.add_some_team_videos() self.logger.info('Adding English language manager and logging in') manager = TeamMemberFactory( role="ROLE_MANAGER", team=self.limited_access_team, user=UserFactory(username='******')) TeamManagerLanguageFactory(member=manager, language='en') self.videos_tab.log_in(manager.user.username, 'password') self.videos_tab.open_videos_tab(self.limited_access_team.slug) self.assertTrue(self.videos_tab.video_has_link(vids[0].title, 'Edit'))
def test_contributor_tasks_permission(self): """Task policy: all team members; contributor sees the task link. """ self.logger.info('setup: Setting task policy to all team members') self.limited_access_team.task_assign_policy = 10 self.limited_access_team.save() vids = self.add_some_team_videos() #Create a user who is a contributor to the team. self.logger.info('Adding user contributor to the team and logging in') contributor = TeamMemberFactory( role="ROLE_CONTRIBUTOR", team=self.limited_access_team, user=UserFactory(username='******')).user self.videos_tab.log_in(contributor.username, 'password') self.videos_tab.open_videos_tab(self.limited_access_team.slug) self.assertTrue(self.videos_tab.video_has_link(vids[0].title, 'Tasks'))
def test_edit_change_team(self): """Edit a video, changing it from 1 team to another. """ video_title = 'qs1-not-transback' team2 = TeamMemberFactory.create(user=self.team_owner).team videos = self.data_utils.create_several_team_videos_with_subs( self.team, self.manager_user) management.call_command('update_index', interactive=False) self.videos_tab.log_in(self.team_owner.username, 'password') self.videos_tab.open_videos_tab(self.team.slug) self.videos_tab.search(video_title) self.videos_tab.edit_video( video=video_title, team=team2.name, ) management.call_command('update_index', interactive=False) self.videos_tab.open_videos_tab(team2.slug) self.assertTrue(self.videos_tab.video_present(video_title))
def create_workflow_team(cls): team = TeamMemberFactory.create( team__workflow_enabled=True, team__translate_policy=20, #any team team__subtitle_policy=20, #any team team__task_assign_policy=10, #any team user=cls.user, ).team cls.workflow = WorkflowFactory( team=team, autocreate_subtitle=True, autocreate_translate=True, approve_allowed=10, # manager review_allowed=10, # peer ) lang_list = ['en', 'ru', 'pt-br', 'de', 'sv'] for language in lang_list: TeamLangPrefFactory.create(team=team, language_code=language, preferred=True) return team
def setUpClass(cls): super(TestCaseVideosDisplay, cls).setUpClass() #management.call_command('flush', interactive=False) cls.data_utils = data_helpers.DataHelpers() cls.videos_tab = videos_tab.VideosTab(cls) cls.tasks_tab = TasksTab(cls) cls.team_owner = UserFactory.create() cls.logger.info('Creating team limited access: workflows enabled, ' 'video policy set to manager and admin, ' 'task assign policy set to manager and admin, ' 'membership policy open.') cls.limited_access_team = TeamMemberFactory.create( team__membership_policy=4, #open team__video_policy=2, #manager and admin team__task_assign_policy=20, #manager and admin team__workflow_enabled=True, user=cls.team_owner, ).team cls.videos_tab.open_page(cls.limited_access_team.slug)
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)