Exemple #1
0
    def test_translators_no_review(self):
        """Translators report generates when no review tasks.
        
        """
        team = self.create_workflow_team()
        wf  = team.get_workflow()
        wf.review_allowed = 0
        wf.save()
        
        vid, tv = self.create_tv_with_original_subs('en', self.owner, team)
        self.data_utils.complete_approve_task(tv, 20, self.admin)

        self.add_translation('de', vid, self.contributor2, complete=True)
        self.data_utils.complete_approve_task(tv, 20, self.admin)
        report = BillingFactory(type=4, 
                                start_date=(datetime.date.today() - 
                                            datetime.timedelta(1)),
                                end_date=datetime.datetime.now(),
                                )
        report.teams=[team]
        report.save()
        report.process()
        bill = 'user-data/%s' % report.csv_file
        entries = self._bill_dict(bill)
        self.assertEqual(4, len(entries))
Exemple #2
0
    def test_translators_no_review(self):
        """Translators report generates when no review tasks.
        
        """
        team, member, member2 = self.create_workflow_team()
        wf = team.get_workflow()
        wf.review_allowed = 0
        wf.save()

        vid = TeamVideoFactory(team=team,
                               video__primary_audio_language_code='en').video
        tv = vid.get_team_video()
        self.add_subtitles('en', vid, member)
        self.data_utils.complete_approve_task(tv, 20, self.admin)

        self.add_subtitles('de', vid, member2, complete=True)
        self.data_utils.complete_approve_task(tv, 20, self.admin)
        report = BillingFactory(
            type=4,
            start_date=(datetime.date.today() - datetime.timedelta(1)),
            end_date=datetime.datetime.now(),
        )
        report.teams = [team]
        report.save()
        report.process()
        bill = 'user-data/%s' % report.csv_file
        entries = self._bill_dict(bill)
        self.assertEqual(4, len(entries))
Exemple #3
0
 def test_prof_services_no_review(self):
     """Profession services report generates when no review tasks.
     
     """
     team = self.create_workflow_team()
     wf  = team.get_workflow()
     wf.review_allowed = 0
     wf.save()
     
     vid, tv = self.create_tv_with_original_subs('en', self.owner, team)
     self.data_utils.complete_approve_task(tv, 20, self.admin)
     self.logger.info('Adding translation for next video')
     self.add_translation('de', vid, self.contributor2, complete=True)
     self.data_utils.complete_approve_task(tv, 20, self.admin)
     report = BillingFactory(type=3, 
                             start_date=(datetime.date.today() - 
                                         datetime.timedelta(1)),
                             end_date=datetime.datetime.now(),
                             )
     report.teams=[team, self.team]
     report.save()
     report.process()
     bill = 'user-data/%s' % report.csv_file
     entries = self._bill_dict(bill)
     # expect 6 entries from the main team + 2 entries from the no review team
     self.assertEqual(8, len(entries))
Exemple #4
0
    def test_translator_report_values(self):
        """Check the content of translation team payment reports.
        
        Report should: 
        - display the video time as a decimal
        - contain separate entries for translator and reviewer
        - show the pay rate for translator and reviewer
        - contain True / False for original language
        - contain any reviewers notes.
        - list the approver, team, title and id.
        """

        team, member, member2 = self.create_workflow_team()
        vid, tv = self.create_tv_with_original_subs('en', self.admin, team)
        self.data_utils.complete_review_task(tv, 20, member)
        self.data_utils.complete_approve_task(tv, 20, self.admin)
        self.add_translation('de', vid, member2, complete=True)
        self.data_utils.complete_review_task(tv, 20, member, 
                                             note = 'Task shared with GabrielJosé') 

        self.data_utils.complete_approve_task(tv, 20, self.admin)
        report = BillingFactory(type=4, 
                                start_date=(datetime.date.today() - 
                                            datetime.timedelta(1)),
                                end_date=datetime.datetime.now(),
                                )
        report.teams=[team]
        report.save()
        report.process()
        bill = 'user-data/%s' % report.csv_file
        entries = self._bill_dict(bill)
        user_tasks = []
        unwanted_fields = ['Video ID', 'Project', 'Team', 'Video Title', 'Approver', 'Date']
        for e in entries:
            [e.pop(x) for x in unwanted_fields]
            user_tasks.append(e)
        expected_translate_data = {  
                            'Task Type': 'Translate', 
                            'Language': 'de', 
                            'Minutes': '2.45015', 
                            'Pay Rate': '',
                            'Note': '', 
                            'User': ("Gabriel Jos\xc3\xa9 de la Concordia "
                                     "Garc\xc3\xada M\xc3\xa1rquez"),
                            'Original': 'False'
                          }

        expected_reviewer_data = {
                                   'Task Type': 'Review', 
                                   'Language': 'de', 
                                   'Minutes': '2.45015', 
                                   'Note': 'Task shared with Gabriel', 
                                   'User': "******".join([self.member.first_name, 
                                                     self.member.last_name]),
                                   'Pay Rate': 'L2',
                                   'Original': 'False',
                                   'Note': 'Task shared with GabrielJos\xc3\xa9'
                                 }
        self.assertIn(expected_translate_data, user_tasks)
        self.assertIn(expected_reviewer_data, user_tasks)
Exemple #5
0
 def create_team_bill(cls):
     report = BillingFactory( start_date=(datetime.date.today() - 
                                         datetime.timedelta(1)),
                             end_date=datetime.datetime.now(),
                             )
     report.teams=[cls.team]
     report.save()
     report.process()
     cls.bill = 'user-data/%s' % report.csv_file
     bill_dict = cls._bill_dict(cls.bill)
     return bill_dict
Exemple #6
0
    def test_prof_services_report_values(self):
        """Check the content of professions services team billing reports.
        
        Report should: 
        - round the minutes up to the nearest whole number
        - contain the True / False for is translation
        - contain True / False for original language
        - contain the language code
        - list the approver
        """

        team, member, member2 = self.create_workflow_team()
        vid = TeamVideoFactory(team=team,
                               video__primary_audio_language_code='en').video
        tv = vid.get_team_video()
        self.add_subtitles('en', vid, member)
        self.data_utils.complete_review_task(tv, 20, member)
        self.data_utils.complete_approve_task(tv, 20, self.admin)
        self.add_subtitles('de', vid, member2, complete=True)
        self.data_utils.complete_review_task(tv, 20, member)
        self.data_utils.complete_approve_task(tv, 20, self.admin)
        report = BillingFactory(
            type=3,
            start_date=(datetime.date.today() - datetime.timedelta(1)),
            end_date=datetime.datetime.now(),
        )
        report.teams = [team, self.team]
        report.save()
        report.process()
        bill = 'user-data/%s' % report.csv_file
        entries = self._bill_dict(bill)
        team_data = []
        unwanted_fields = [
            'Video ID', 'Project', 'Team', 'Video Title', 'Approver', 'Date'
        ]
        for e in entries:
            [e.pop(x) for x in unwanted_fields]
            team_data.append(e)
        expected_translation_data = {
            'Translation?': 'True',
            'Language': 'de',
            'Minutes': '2.45015',
            'Original': 'False'
        }

        expected_orig_lang_data = {
            'Translation?': 'False',
            'Language': 'en',
            'Minutes': '2.45015',
            'Original': 'True'
        }

        self.assertIn(expected_translation_data, team_data)
        self.assertIn(expected_orig_lang_data, team_data)
Exemple #7
0
 def test_crowd_billing_fields(self):
     video, tv = self._create_tv_with_original_subs(self.user, self.team)
     report = BillingFactory(start_date=(datetime.date.today() - 
                                         datetime.timedelta(1)),
                             end_date=datetime.datetime.now(),
                             )
     report.teams=[self.team]
     report.save()
     report.process()
     bill = csv.DictReader(open('user-data/%s' %report.csv_file))
     expected_fields = ['Video Title', 'Video ID', 'Language', 'Minutes', 
                        'Original', 'Language number', 'Team', 'Created', 'Source', 'User']
     self.assertEqual(expected_fields, bill.fieldnames)
Exemple #8
0
 def test_professional_svcs_report(self):
     """Professional svcs report only contains approved videos."""
     report = BillingFactory(
         type=3,
         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
     entries = self._bill_dict(bill)
     self.assertEqual(6, len(entries))
Exemple #9
0
 def test_translators_report(self):
     """Translator reports have rev and trnsltr entries for approved vids"""
     report = BillingFactory(
         type=4,
         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
     entries = self._bill_dict(bill)
     self.assertEqual(18, len(entries))
Exemple #10
0
    def test_delete_video(self):

        video1, tv1 = self._create_tv_with_original_subs(self.member, self.team)
        video, tv = self._create_tv_with_original_subs(self.member, self.team)
        video.delete()
        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.assertIn('deleted', bill_dict.keys())
Exemple #11
0
    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'])
Exemple #12
0
    def test_incomplete(self):
        """Incomplete languages have no billing record. """
        video, tv = self._create_tv_with_original_subs(self.user, self.team)
        inc_video, inc_tv = self._create_tv_with_original_subs(self.user, 
                                                               self.team, 
                                                               complete=False)

        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.assertNotIn(inc_video.video_id, bill_dict.keys())