Exemplo n.º 1
0
    def test_empty_report_addon_reviewer(self):
        command = Command()
        data = command.fetch_report_data('addon')
        assert data == [
            ('Weekly Add-on Reviews, 5 Reviews or More', [
                'Name', 'Staff', 'Total Risk', 'Average Risk', 'Points',
                'Add-ons Reviewed'
            ], ()),
            ('Weekly Volunteer Contribution Ratio',
             ['Group', 'Total Risk', 'Average Risk',
              'Add-ons Reviewed'], ((u'All Reviewers', u'-', u'-', u'0'),
                                    (u'Volunteers', u'-', u'-', u'0'))),
            ('Weekly Add-on Reviews by Risk Profiles',
             ['Risk Category', 'All Reviewers', 'Volunteers'], ()),
            ('Quarterly contributions', ['Name', 'Points',
                                         'Add-ons Reviewed'], ())
        ]

        html = command.generate_report_html('addon', data)

        assert 'Weekly Add-on Reviews Report' in html
        assert 'Volunteer A' not in html
        assert 'Staff B' not in html
        assert 'Deleted' not in html

        to = '*****@*****.**'
        subject = '%s %s-%s' % ('Weekly Add-on Reviews Report',
                                self.last_week_begin, self.last_week_end)
        command.mail_report(to, subject, html)

        assert len(mail.outbox) == 1
        email = mail.outbox[0]
        assert to in email.to
        assert subject in email.subject
Exemplo n.º 2
0
    def test_empty_report_content_reviewer(self):
        command = Command()
        data = command.fetch_report_data('content')

        assert data == [('Weekly Content Reviews, 10 Reviews or More',
                         ['Name', 'Staff', 'Points', 'Add-ons Reviewed'], ()),
                        ('Weekly Volunteer Contribution Ratio',
                         ['Group', 'Add-ons Reviewed'],
                         ((u'All Reviewers', u'0'), (u'Volunteers', u'0'))),
                        ('Quarterly contributions',
                         ['Name', 'Points', 'Add-ons Reviewed'], ())]

        html = command.generate_report_html('content', data)

        assert 'Weekly Add-on Content Reviews Report' in html
        assert 'Firefox user' not in html
        assert 'Staff Content D' not in html
        assert 'Deleted' not in html

        to = '*****@*****.**'
        subject = '%s %s-%s' % ('Weekly Add-on Content Reviews Report',
                                self.last_week_begin, self.last_week_end)
        command.mail_report(to, subject, html)

        assert len(mail.outbox) == 1
        email = mail.outbox[0]
        assert to in email.to
        assert subject in email.subject
Exemplo n.º 3
0
    def test_empty_report_content_reviewer(self):
        command = Command()
        data = command.fetch_report_data('content')

        assert data == [
            ('Weekly Content Reviews, 10 Reviews or More',
             ['Name', 'Staff', 'Points', 'Add-ons Reviewed'],
             ()),
            ('Weekly Volunteer Contribution Ratio',
             ['Group', 'Add-ons Reviewed'],
             ((u'All Reviewers', u'0'), (u'Volunteers', u'0'))),
            ('Quarterly contributions',
             ['Name', 'Points', 'Add-ons Reviewed'],
             ())
        ]

        html = command.generate_report_html('content', data)

        assert 'Weekly Add-on Content Reviews Report' in html
        assert 'Firefox user' not in html
        assert 'Staff Content D' not in html
        assert 'Deleted' not in html

        to = '*****@*****.**'
        subject = '%s %s-%s' % (
                  'Weekly Add-on Content Reviews Report',
                  self.last_week_begin, self.last_week_end)
        command.mail_report(to, subject, html)

        assert len(mail.outbox) == 1
        email = mail.outbox[0]
        assert to in email.to
        assert subject in email.subject
Exemplo n.º 4
0
    def test_report_content_reviewer(self):
        self.generate_review_data()
        command = Command()
        data = command.fetch_report_data('content')

        expected = [
            (
                'Weekly Content Reviews, 10 Reviews or More',
                ['Name', 'Staff', 'Points', 'Add-ons Reviewed'],
                (
                    ('Firefox user {}'.format(self.reviewer3.id), '', '140',
                     '14'),
                    ('Staff Content D', '*', '-', '10'),
                ),
            ),
            (
                'Weekly Volunteer Contribution Ratio',
                ['Group', 'Add-ons Reviewed'],
                (('All Reviewers', '24'), ('Volunteers', '14')),
            ),
            (
                'Quarterly contributions',
                ['Name', 'Points', 'Add-ons Reviewed'],
                # Empty here to cover edge-case, see below.
                (),
            ),
        ]
        # If 'last_week_begin', which is used to generate the review data
        # (see `generate_review_data`), doesn't fall into the previous quarter,
        # fill in quarterly contributions.
        if not self.last_week_begin < self.this_quarter_begin:
            expected[2] = (
                'Quarterly contributions',
                ['Name', 'Points', 'Add-ons Reviewed'],
                (('Firefox user {}'.format(self.reviewer3.id), '140', '14'), ),
            )
        assert data == expected

        html = command.generate_report_html('content', data)

        assert 'Weekly Add-on Content Reviews Report' in html
        assert 'Firefox user {}'.format(self.reviewer3.id) in html
        assert 'Staff Content D' in html
        assert 'Deleted' not in html

        to = '*****@*****.**'
        subject = '%s %s-%s' % (
            'Weekly Add-on Content Reviews Report',
            self.last_week_begin,
            self.last_week_end,
        )
        command.mail_report(to, subject, html)

        assert len(mail.outbox) == 1
        email = mail.outbox[0]
        assert to in email.to
        assert subject in email.subject
Exemplo n.º 5
0
    def test_report_addon_reviewer(self):
        self.generate_review_data()
        command = Command()
        data = command.fetch_report_data('addon')
        expected = [
            ('Weekly Add-on Reviews, 5 Reviews or More', [
                'Name', 'Staff', 'Total Risk', 'Average Risk', 'Points',
                'Add-ons Reviewed'
            ], ((u'Staff B', u'*', u'10,212', u'1,458.86', '-', u'7'),
                (u'Volunteer A', u'', u'2,393', u'265.89', '810', u'9'))),
            ('Weekly Volunteer Contribution Ratio',
             ['Group', 'Total Risk', 'Average Risk', 'Add-ons Reviewed'
              ], ((u'All Reviewers', u'12,605', u'787.81', u'16'),
                  (u'Volunteers', u'2,393', u'265.89', u'9'))),
            ('Weekly Add-on Reviews by Risk Profiles',
             ['Risk Category', 'All Reviewers',
              'Volunteers'], ((u'highest', u'6', u'3'), (u'high', u'3', u'1'),
                              (u'medium', u'4', u'3'), (u'low', u'3', u'2'))),
            (
                'Quarterly contributions',
                ['Name', 'Points', 'Add-ons Reviewed'],
                # Empty here to cover edge-case, see below.
                ())
        ]
        # If 'last_week_begin', which is used to generate the review data
        # (see `generate_review_data`), doesn't fall into the previous quarter,
        # fill in quarterly contributions.
        if not self.last_week_begin < self.this_quarter_begin:
            expected[3] = ('Quarterly contributions',
                           ['Name', 'Points', 'Add-ons Reviewed'
                            ], ((u'Volunteer A', u'810', u'9'), ))
        assert data == expected

        html = command.generate_report_html('addon', data)

        assert 'Weekly Add-on Reviews Report' in html
        assert 'Volunteer A' in html
        assert 'Staff B' in html
        assert 'Deleted' not in html

        to = '*****@*****.**'
        subject = '%s %s-%s' % ('Weekly Add-on Reviews Report',
                                self.last_week_begin, self.last_week_end)
        command.mail_report(to, subject, html)

        assert len(mail.outbox) == 1
        email = mail.outbox[0]
        assert to in email.to
        assert subject in email.subject
Exemplo n.º 6
0
    def test_report_addon_reviewer(self):
        self.generate_review_data()
        command = Command()
        data = command.fetch_report_data('addon')
        expected = [
            ('Weekly Add-on Reviews, 5 Reviews or More',
             ['Name', 'Staff', 'Total Risk', 'Average Risk', 'Points',
              'Add-ons Reviewed'],
             ((u'Staff B', u'*', u'10,212', u'1,458.86', '-', u'7'),
              (u'Volunteer A', u'', u'2,393', u'265.89', '810', u'9'))),
            ('Weekly Volunteer Contribution Ratio',
             ['Group', 'Total Risk', 'Average Risk', 'Add-ons Reviewed'],
             ((u'All Reviewers', u'12,605', u'787.81', u'16'),
              (u'Volunteers', u'2,393', u'265.89', u'9'))),
            ('Weekly Add-on Reviews by Risk Profiles',
             ['Risk Category', 'All Reviewers', 'Volunteers'],
             ((u'highest', u'6', u'3'), (u'high', u'3', u'1'),
              (u'medium', u'4', u'3'), (u'low', u'3', u'2'))),
            ('Quarterly contributions',
             ['Name', 'Points', 'Add-ons Reviewed'],
             # Empty here to cover edge-case, see below.
             ())
        ]
        # If 'last_week_begin', which is used to generate the review data
        # (see `generate_review_data`), doesn't fall into the previous quarter,
        # fill in quarterly contributions.
        if not self.last_week_begin < self.this_quarter_begin:
            expected[3] = ('Quarterly contributions',
                           ['Name', 'Points', 'Add-ons Reviewed'],
                           ((u'Volunteer A', u'810', u'9'),))
        assert data == expected

        html = command.generate_report_html('addon', data)

        assert 'Weekly Add-on Reviews Report' in html
        assert 'Volunteer A' in html
        assert 'Staff B' in html
        assert 'Deleted' not in html

        to = '*****@*****.**'
        subject = '%s %s-%s' % (
                  'Weekly Add-on Reviews Report',
                  self.last_week_begin, self.last_week_end)
        command.mail_report(to, subject, html)

        assert len(mail.outbox) == 1
        email = mail.outbox[0]
        assert to in email.to
        assert subject in email.subject
Exemplo n.º 7
0
    def test_report_content_reviewer(self):
        self.generate_review_data()
        command = Command()
        data = command.fetch_report_data('content')

        expected = [
            ('Weekly Content Reviews, 10 Reviews or More',
             ['Name', 'Staff', 'Points', 'Add-ons Reviewed'],
             ((u'Firefox user {}'.format(self.reviewer3.id),
               u'', '120', u'12'),
              (u'Staff Content D', u'*', '-', u'10'))),
            ('Weekly Volunteer Contribution Ratio',
             ['Group', 'Add-ons Reviewed'],
             ((u'All Reviewers', u'22'), (u'Volunteers', u'12'))),
            ('Quarterly contributions',
             ['Name', 'Points', 'Add-ons Reviewed'],
             # Empty here to cover edge-case, see below.
             ())
        ]
        # If 'last_week_begin', which is used to generate the review data
        # (see `generate_review_data`), doesn't fall into the previous quarter,
        # fill in quarterly contributions.
        if not self.last_week_begin < self.this_quarter_begin:
            expected[2] = ('Quarterly contributions',
                           ['Name', 'Points', 'Add-ons Reviewed'],
                           ((u'Firefox user {}'.format(self.reviewer3.id),
                             u'120', u'12'),))
        assert data == expected

        html = command.generate_report_html('content', data)

        assert 'Weekly Add-on Content Reviews Report' in html
        assert 'Firefox user {}'.format(self.reviewer3.id) in html
        assert 'Staff Content D' in html
        assert 'Deleted' not in html

        to = '*****@*****.**'
        subject = '%s %s-%s' % (
                  'Weekly Add-on Content Reviews Report',
                  self.last_week_begin, self.last_week_end)
        command.mail_report(to, subject, html)

        assert len(mail.outbox) == 1
        email = mail.outbox[0]
        assert to in email.to
        assert subject in email.subject
    def test_report_addon_reviewer(self):
        self.generate_review_data()
        command = Command()
        data = command.fetch_report_data('addon')
        assert data == [
            ('Weekly Add-on Reviews, 5 Reviews or More', [
                'Name', 'Staff', 'Total Risk', 'Average Risk', 'Points',
                'Add-ons Reviewed'
            ], ((u'Staff B', u'*', u'10,212', u'1,458.86', '-', u'7'),
                (u'Volunteer A', u'', u'2,393', u'265.89', '810', u'9'))),
            ('Weekly Volunteer Contribution Ratio',
             ['Group', 'Total Risk', 'Average Risk', 'Add-ons Reviewed'
              ], ((u'All Reviewers', u'12,605', u'787.81', u'16'),
                  (u'Volunteers', u'2,393', u'265.89', u'9'))),
            ('Weekly Add-on Reviews by Risk Profiles',
             ['Risk Category', 'All Reviewers',
              'Volunteers'], ((u'highest', u'6', u'3'), (u'high', u'3', u'1'),
                              (u'medium', u'4', u'3'), (u'low', u'3', u'2'))),
            ('Quarterly contributions', ['Name', 'Points', 'Add-ons Reviewed'],
             ((u'Volunteer A', u'810', u'9'), ))
        ]

        html = command.generate_report_html('addon', data)

        assert 'Weekly Add-on Reviews Report' in html
        assert 'Volunteer A' in html
        assert 'Staff B' in html

        to = '*****@*****.**'
        subject = '%s %s-%s' % ('Weekly Add-on Reviews Report',
                                self.last_week_begin, self.last_week_end)
        command.mail_report(to, subject, html)

        assert len(mail.outbox) == 1
        email = mail.outbox[0]
        assert to in email.to
        assert subject in email.subject
Exemplo n.º 9
0
    def test_empty_report_addon_reviewer(self):
        command = Command()
        data = command.fetch_report_data('addon')
        assert data == [
            ('Weekly Add-on Reviews, 5 Reviews or More',
             ['Name', 'Staff', 'Total Risk', 'Average Risk', 'Points',
              'Add-ons Reviewed'],
             ()),
            ('Weekly Volunteer Contribution Ratio',
             ['Group', 'Total Risk', 'Average Risk', 'Add-ons Reviewed'],
             ((u'All Reviewers', u'-', u'-', u'0'),
              (u'Volunteers', u'-', u'-', u'0'))),
            ('Weekly Add-on Reviews by Risk Profiles',
             ['Risk Category', 'All Reviewers', 'Volunteers'],
             ()),
            ('Quarterly contributions',
             ['Name', 'Points', 'Add-ons Reviewed'],
             ())
        ]

        html = command.generate_report_html('addon', data)

        assert 'Weekly Add-on Reviews Report' in html
        assert 'Volunteer A' not in html
        assert 'Staff B' not in html
        assert 'Deleted' not in html

        to = '*****@*****.**'
        subject = '%s %s-%s' % (
                  'Weekly Add-on Reviews Report',
                  self.last_week_begin, self.last_week_end)
        command.mail_report(to, subject, html)

        assert len(mail.outbox) == 1
        email = mail.outbox[0]
        assert to in email.to
        assert subject in email.subject