Example #1
0
 def test_with_date(self, _render):
     date = datetime.date(2001, 1, 11)
     process_iarc_changes(date.strftime('%Y-%m-%d'))
     _render.assert_called_with('get_rating_changes.xml', {
         'date_from': date - datetime.timedelta(days=1),
         'date_to': date,
     })
Example #2
0
 def test_with_date(self, _render):
     date = datetime.date(2001, 1, 11)
     process_iarc_changes(date.strftime('%Y-%m-%d'))
     _render.assert_called_with('get_rating_changes.xml', {
         'date_from': date - datetime.timedelta(days=1),
         'date_to': date,
     })
Example #3
0
    def test_processing(self):
        """
        The mock client always returns the same data. Set up the app so it
        matches the submission ID and verify the data is saved as expected.
        """
        app = amo.tests.app_factory()
        IARCInfo.objects.create(addon=app, submission_id=52,
                                security_code='FZ32CU8')
        app.set_content_ratings({
            mkt.ratingsbodies.CLASSIND: mkt.ratingsbodies.CLASSIND_L,
            mkt.ratingsbodies.ESRB: mkt.ratingsbodies.ESRB_E
        })

        process_iarc_changes()

        app = app.reload()

        # Check ratings.
        # CLASSIND should get updated. ESRB should stay the same.
        cr = app.content_ratings.get(
            ratings_body=mkt.ratingsbodies.CLASSIND.id)
        eq_(cr.rating, mkt.ratingsbodies.CLASSIND_18.id)
        cr = app.content_ratings.get(ratings_body=mkt.ratingsbodies.ESRB.id)
        eq_(cr.rating, mkt.ratingsbodies.ESRB_E.id)

        # Check descriptors.
        self.assertSetEqual(
            app.rating_descriptors.to_keys(),
            ['has_classind_shocking', 'has_classind_sex_content',
             'has_classind_drugs', 'has_classind_lang', 'has_classind_nudity',
             'has_classind_violence_extreme'])
Example #4
0
 def test_no_date(self, _render):
     process_iarc_changes()
     _render.assert_called_with(
         'get_rating_changes.xml', {
             'date_from':
             datetime.date.today() - datetime.timedelta(days=1),
             'date_to': datetime.date.today(),
         })
Example #5
0
    def test_get_ratings_changes_is_called(self, get_rating_changes_mock):
        process_iarc_changes()
        eq_(get_rating_changes_mock.call_count, 1)
        eq_(get_rating_changes_mock.call_args[0], ())
        eq_(get_rating_changes_mock.call_args[1], {'date': None})

        get_rating_changes_mock.reset_mock()
        start_date = self.days_ago(1)
        process_iarc_changes(start_date)
        eq_(get_rating_changes_mock.call_count, 1)
        eq_(get_rating_changes_mock.call_args[0], ())
        eq_(get_rating_changes_mock.call_args[1], {'date': start_date})
Example #6
0
    def test_processing(self):
        """
        The mock client always returns the same data. Set up the app so it
        matches the submission ID and verify the data is saved as expected.
        """
        amo.set_user(amo.tests.user_factory())
        app = amo.tests.app_factory()
        IARCInfo.objects.create(addon=app,
                                submission_id=52,
                                security_code='FZ32CU8')
        app.set_descriptors([
            'has_classind_violence',
            'has_esrb_strong_lang',
            'has_pegi_language',
            'has_pegi_online',
            'has_usk_lang',
        ])
        app.set_interactives([])
        app.set_content_ratings(
            {mkt.ratingsbodies.CLASSIND: mkt.ratingsbodies.CLASSIND_L})

        process_iarc_changes()
        app = app.reload()

        # Check ratings. CLASSIND should get updated.
        cr = app.content_ratings.get(
            ratings_body=mkt.ratingsbodies.CLASSIND.id)
        eq_(cr.rating, mkt.ratingsbodies.CLASSIND_14.id)
        cr = app.content_ratings.get(ratings_body=mkt.ratingsbodies.ESRB.id)
        eq_(cr.rating, mkt.ratingsbodies.ESRB_M.id)

        assert ActivityLog.objects.filter(
            action=amo.LOG.CONTENT_RATING_CHANGED.id).count()

        # Check descriptors.
        rd = RatingDescriptors.objects.get(addon=app)
        self.assertSetEqual(rd.to_keys(), [
            'has_esrb_strong_lang',
            'has_classind_lang',
            'has_pegi_lang',
            'has_pegi_online',
            'has_usk_lang',
        ])

        # Check interactives.
        ri = RatingInteractives.objects.get(addon=app)
        self.assertSetEqual(ri.to_keys(), [
            'has_shares_info', 'has_shares_location', 'has_digital_purchases',
            'has_users_interact'
        ])
Example #7
0
    def test_processing(self):
        """
        The mock client always returns the same data. Set up the app so it
        matches the submission ID and verify the data is saved as expected.
        """
        amo.set_user(amo.tests.user_factory())
        app = amo.tests.app_factory()
        IARCInfo.objects.create(addon=app, submission_id=52,
                                security_code='FZ32CU8')
        app.set_descriptors([
            'has_classind_violence',
            'has_esrb_strong_lang',
            'has_pegi_language', 'has_pegi_online',
            'has_usk_lang',
        ])
        app.set_interactives([])
        app.set_content_ratings({
            mkt.ratingsbodies.CLASSIND: mkt.ratingsbodies.CLASSIND_L
        })

        process_iarc_changes()
        app = app.reload()

        # Check ratings. CLASSIND should get updated.
        cr = app.content_ratings.get(
            ratings_body=mkt.ratingsbodies.CLASSIND.id)
        eq_(cr.rating, mkt.ratingsbodies.CLASSIND_14.id)
        cr = app.content_ratings.get(ratings_body=mkt.ratingsbodies.ESRB.id)
        eq_(cr.rating, mkt.ratingsbodies.ESRB_M.id)

        assert ActivityLog.objects.filter(
            action=amo.LOG.CONTENT_RATING_CHANGED.id).count()

        # Check descriptors.
        rd = RatingDescriptors.objects.get(addon=app)
        self.assertSetEqual(rd.to_keys(), [
            'has_esrb_strong_lang',
            'has_classind_lang',
            'has_pegi_lang', 'has_pegi_online',
            'has_usk_lang',
        ])

        # Check interactives.
        ri = RatingInteractives.objects.get(addon=app)
        self.assertSetEqual(ri.to_keys(), [
            'has_shares_info', 'has_shares_location', 'has_digital_purchases',
            'has_users_interact'
        ])
Example #8
0
    def test_processing(self):
        """
        The mock client always returns the same data. Set up the app so it
        matches the submission ID and verify the data is saved as expected.
        """
        amo.set_user(amo.tests.user_factory())
        app = amo.tests.app_factory()
        IARCInfo.objects.create(addon=app, submission_id=52,
                                security_code='FZ32CU8')
        app.set_content_ratings({
            mkt.ratingsbodies.CLASSIND: mkt.ratingsbodies.CLASSIND_L,
            mkt.ratingsbodies.ESRB: mkt.ratingsbodies.ESRB_E
        })

        process_iarc_changes()
        app = app.reload()

        # Check ratings.
        # CLASSIND should get updated. ESRB should stay the same.
        cr = app.content_ratings.get(
            ratings_body=mkt.ratingsbodies.CLASSIND.id)
        eq_(cr.rating, mkt.ratingsbodies.CLASSIND_18.id)
        cr = app.content_ratings.get(ratings_body=mkt.ratingsbodies.ESRB.id)
        eq_(cr.rating, mkt.ratingsbodies.ESRB_E.id)

        assert ActivityLog.objects.filter(
            action=amo.LOG.CONTENT_RATING_CHANGED.id).count()

        # Check descriptors.
        self.assertSetEqual(
            app.rating_descriptors.to_keys(),
            ['has_classind_shocking', 'has_classind_sex_content',
             'has_classind_drugs', 'has_classind_lang', 'has_classind_nudity',
             'has_classind_violence_extreme'])
        self.assertSetEqual(
            app.rating_interactives.to_keys(),
            ['has_shares_location', 'has_shares_info'])
Example #9
0
 def test_no_date(self, _render):
     process_iarc_changes()
     _render.assert_called_with('get_rating_changes.xml', {
         'date_from': datetime.date.today() - datetime.timedelta(days=1),
         'date_to': datetime.date.today(),
     })
Example #10
0
 def test_with_date(self, _render):
     date = datetime.date(2001, 1, 11)
     process_iarc_changes(date.strftime("%Y-%m-%d"))
     _render.assert_called_with(
         "get_rating_changes.xml", {"date_from": date - datetime.timedelta(days=1), "date_to": date}
     )
Example #11
0
 def test_no_date(self, _render):
     process_iarc_changes()
     _render.assert_called_with(
         "get_rating_changes.xml",
         {"date_from": datetime.date.today() - datetime.timedelta(days=1), "date_to": datetime.date.today()},
     )