Beispiel #1
0
    def test_adu_flag(self):
        addon = Addon.objects.get(pk=3615)

        now = datetime.datetime.now()
        counter = UpdateCount.objects.create(addon=addon, date=now, count=1234)
        counter.save()

        self.assertTrue(
            addon.average_daily_users > addon.total_downloads + 10000,
            "Unexpected ADU count. ADU of %d not greater than %d"
            % (addon.average_daily_users, addon.total_downloads + 10000),
        )

        adu = cron.update_addon_average_daily_users
        flag_database("new", "old", "alias")
        try:
            # Should fail.
            self.assertRaises(CommandError, adu)

            # Should work with the environ flag.
            os.environ["FORCE_INDEXING"] = "1"
            adu()
        finally:
            unflag_database()
            del os.environ["FORCE_INDEXING"]

        addon = Addon.objects.get(pk=3615)
        eq_(addon.average_daily_users, 1234)
Beispiel #2
0
    def test_adu_flag(self):
        addon = Addon.objects.get(pk=3615)

        now = datetime.datetime.now()
        counter = UpdateCount.objects.create(addon=addon, date=now, count=1234)
        counter.save()

        self.assertTrue(
            addon.average_daily_users > addon.total_downloads + 10000,
            'Unexpected ADU count. ADU of %d not greater than %d' %
            (addon.average_daily_users, addon.total_downloads + 10000))

        adu = cron.update_addon_average_daily_users
        flag_database('new', 'old', 'alias')
        try:
            # Should fail.
            self.assertRaises(CommandError, adu)

            # Should work with the environ flag.
            os.environ['FORCE_INDEXING'] = '1'
            adu()
        finally:
            unflag_database()
            del os.environ['FORCE_INDEXING']

        addon = Addon.objects.get(pk=3615)
        eq_(addon.average_daily_users, 1234)
Beispiel #3
0
    def test_weekly_downloads_flagged(self):
        eq_(self.get_webapp().weekly_downloads, 0)
        self.add_install()
        self.add_install(user=UserProfile.objects.get(pk=10482), created=datetime.today() - timedelta(days=2))

        flag_database("new", "old", "alias")
        try:
            # Should fail.
            self.assertRaises(CommandError, update_weekly_downloads)
            eq_(self.get_webapp().weekly_downloads, 0)

            # Should work with the environ flag.
            os.environ["FORCE_INDEXING"] = "1"
            update_weekly_downloads()
        finally:
            unflag_database()
            del os.environ["FORCE_INDEXING"]

        eq_(self.get_webapp().weekly_downloads, 2)
Beispiel #4
0
    def test_weekly_downloads_flagged(self):
        eq_(self.get_webapp().weekly_downloads, 0)
        self.add_install()
        self.add_install(user=UserProfile.objects.get(pk=10482),
                         created=datetime.today() - timedelta(days=2))

        flag_database('new', 'old', 'alias')
        try:
            # Should fail.
            self.assertRaises(CommandError, update_weekly_downloads)
            eq_(self.get_webapp().weekly_downloads, 0)

            # Should work with the environ flag.
            os.environ['FORCE_INDEXING'] = '1'
            update_weekly_downloads()
        finally:
            unflag_database()
            del os.environ['FORCE_INDEXING']

        eq_(self.get_webapp().weekly_downloads, 2)