Exemple #1
0
 def test_user_total(self):
     day = datetime.date(2009, 1, 1)
     p = UserProfile.objects.create(username="******", source=amo.LOGIN_SOURCE_MMO_BROWSERID)
     p.update(created=day)
     eq_(tasks._get_monolith_jobs(day)["mmo_user_count_total"][0]["count"](), 1)
     eq_(tasks._get_monolith_jobs()["mmo_user_count_total"][0]["count"](), 1)
     eq_(tasks._get_monolith_jobs()["mmo_user_count_new"][0]["count"](), 0)
Exemple #2
0
 def test_user_total(self):
     day = datetime.date(2009, 1, 1)
     p = UserProfile.objects.create(username='******',
                                    source=amo.LOGIN_SOURCE_MMO_BROWSERID)
     p.update(created=day)
     eq_(
         tasks._get_monolith_jobs(day)['mmo_user_count_total'][0]['count']
         (), 1)
     eq_(tasks._get_monolith_jobs()['mmo_user_count_total'][0]['count'](),
         1)
     eq_(tasks._get_monolith_jobs()['mmo_user_count_new'][0]['count'](), 0)
Exemple #3
0
    def test_dev_total(self):
        p1 = UserProfile.objects.create(username="******", source=amo.LOGIN_SOURCE_MMO_BROWSERID)
        p2 = UserProfile.objects.create(username="******", source=amo.LOGIN_SOURCE_MMO_BROWSERID)
        a1 = amo.tests.addon_factory()
        a2 = amo.tests.app_factory()
        AddonUser.objects.create(addon=a1, user=p1)
        AddonUser.objects.create(addon=a1, user=p2)
        AddonUser.objects.create(addon=a2, user=p1)

        eq_(tasks._get_monolith_jobs()["mmo_developer_count_total"][0]["count"](), 1)
Exemple #4
0
    def test_dev_total(self):
        p1 = UserProfile.objects.create(username='******',
                                        source=amo.LOGIN_SOURCE_MMO_BROWSERID)
        p2 = UserProfile.objects.create(username='******',
                                        source=amo.LOGIN_SOURCE_MMO_BROWSERID)
        a1 = amo.tests.addon_factory()
        a2 = amo.tests.app_factory()
        AddonUser.objects.create(addon=a1, user=p1)
        AddonUser.objects.create(addon=a1, user=p2)
        AddonUser.objects.create(addon=a2, user=p1)

        eq_(
            tasks._get_monolith_jobs()['mmo_developer_count_total'][0]['count']
            (), 1)
Exemple #5
0
    def test_app_avail_counts(self):
        today = datetime.date(2013, 1, 25)
        app = Addon.objects.create(type=amo.ADDON_WEBAPP, status=amo.STATUS_PUBLIC)
        # Create a couple more to test the counts.
        Addon.objects.create(type=amo.ADDON_WEBAPP, status=amo.STATUS_PENDING)
        Addon.objects.create(type=amo.ADDON_WEBAPP, status=amo.STATUS_PUBLIC, disabled_by_user=True)

        package_type = "packaged" if app.is_packaged else "hosted"
        premium_type = amo.ADDON_PREMIUM_API[app.premium_type]

        # Add a region exclusion.
        regions = dict(REGIONS_CHOICES_SLUG)
        excluded_region = regions["br"]
        app.addonexcludedregion.create(region=excluded_region.id)

        jobs = tasks._get_monolith_jobs(today)

        # Check package type counts.
        for job in jobs["apps_available_by_package_type"]:
            r = job["dimensions"]["region"]
            p = job["dimensions"]["package_type"]
            if r != excluded_region.slug and p == package_type:
                expected_count = 1
            else:
                expected_count = 0
            count = job["count"]()
            eq_(
                count,
                expected_count,
                "Incorrect count for region %s, package type %s. "
                "Got %d, expected %d." % (r, p, count, expected_count),
            )

        # Check premium type counts.
        for job in jobs["apps_available_by_premium_type"]:
            r = job["dimensions"]["region"]
            p = job["dimensions"]["premium_type"]
            if r != excluded_region.slug and p == premium_type:
                expected_count = 1
            else:
                expected_count = 0
            count = job["count"]()
            eq_(
                count,
                expected_count,
                "Incorrect count for region %s, premium type %s. "
                "Got %d, expected %d." % (r, p, count, expected_count),
            )
Exemple #6
0
    def test_app_avail_counts(self):
        today = datetime.date(2013, 1, 25)
        app = Addon.objects.create(type=amo.ADDON_WEBAPP,
                                   status=amo.STATUS_PUBLIC)
        # Create a couple more to test the counts.
        Addon.objects.create(type=amo.ADDON_WEBAPP, status=amo.STATUS_PENDING)
        Addon.objects.create(type=amo.ADDON_WEBAPP,
                             status=amo.STATUS_PUBLIC,
                             disabled_by_user=True)

        package_type = 'packaged' if app.is_packaged else 'hosted'
        premium_type = amo.ADDON_PREMIUM_API[app.premium_type]

        # Add a region exclusion.
        regions = dict(REGIONS_CHOICES_SLUG)
        excluded_region = regions['br']
        app.addonexcludedregion.create(region=excluded_region.id)

        jobs = tasks._get_monolith_jobs(today)

        # Check package type counts.
        for job in jobs['apps_available_by_package_type']:
            r = job['dimensions']['region']
            p = job['dimensions']['package_type']
            if r != excluded_region.slug and p == package_type:
                expected_count = 1
            else:
                expected_count = 0
            count = job['count']()
            eq_(
                count, expected_count,
                'Incorrect count for region %s, package type %s. '
                'Got %d, expected %d.' % (r, p, count, expected_count))

        # Check premium type counts.
        for job in jobs['apps_available_by_premium_type']:
            r = job['dimensions']['region']
            p = job['dimensions']['premium_type']
            if r != excluded_region.slug and p == premium_type:
                expected_count = 1
            else:
                expected_count = 0
            count = job['count']()
            eq_(
                count, expected_count,
                'Incorrect count for region %s, premium type %s. '
                'Got %d, expected %d.' % (r, p, count, expected_count))
Exemple #7
0
    def test_app_added_counts(self):
        today = datetime.date(2013, 1, 25)
        app = Addon.objects.create(type=amo.ADDON_WEBAPP)
        app.update(created=today)

        package_type = 'packaged' if app.is_packaged else 'hosted'
        premium_type = amo.ADDON_PREMIUM_API[app.premium_type]

        # Add a region exclusion.
        regions = dict(REGIONS_CHOICES_SLUG)
        excluded_region = regions['br']
        app.addonexcludedregion.create(region=excluded_region.id)

        jobs = tasks._get_monolith_jobs(today)

        # Check package type counts.
        for job in jobs['apps_added_by_package_type']:
            r = job['dimensions']['region']
            p = job['dimensions']['package_type']
            if (r != excluded_region.slug and p == package_type):
                expected_count = 1
            else:
                expected_count = 0
            count = job['count']()
            eq_(
                count, expected_count,
                'Incorrect count for region %s, package type %s. '
                'Got %d, expected %d.' % (r, p, count, expected_count))

        # Check premium type counts.
        for job in jobs['apps_added_by_premium_type']:
            r = job['dimensions']['region']
            p = job['dimensions']['premium_type']
            if (r != excluded_region.slug and p == premium_type):
                expected_count = 1
            else:
                expected_count = 0
            count = job['count']()
            eq_(
                count, expected_count,
                'Incorrect count for region %s, premium type %s. '
                'Got %d, expected %d.' % (r, p, count, expected_count))
Exemple #8
0
    def test_app_added_counts(self):
        today = datetime.date(2013, 1, 25)
        app = Addon.objects.create(type=amo.ADDON_WEBAPP)
        app.update(created=today)

        package_type = 'packaged' if app.is_packaged else 'hosted'
        premium_type = amo.ADDON_PREMIUM_API[app.premium_type]

        # Add a region exclusion.
        regions = dict(REGIONS_CHOICES_SLUG)
        excluded_region = regions['br']
        app.addonexcludedregion.create(region=excluded_region.id)

        jobs = tasks._get_monolith_jobs(today)

        # Check package type counts.
        for job in jobs['apps_added_by_package_type']:
            r = job['dimensions']['region']
            p = job['dimensions']['package_type']
            if (r != excluded_region.slug and p == package_type):
                expected_count = 1
            else:
                expected_count = 0
            count = job['count']()
            eq_(count, expected_count,
                'Incorrect count for region %s, package type %s. '
                'Got %d, expected %d.' % (r, p, count, expected_count))

        # Check premium type counts.
        for job in jobs['apps_added_by_premium_type']:
            r = job['dimensions']['region']
            p = job['dimensions']['premium_type']
            if (r != excluded_region.slug and p == premium_type):
                expected_count = 1
            else:
                expected_count = 0
            count = job['count']()
            eq_(count, expected_count,
                'Incorrect count for region %s, premium type %s. '
                'Got %d, expected %d.' % (r, p, count, expected_count))
Exemple #9
0
 def test_user_new(self):
     UserProfile.objects.create(username='******',
                                source=amo.LOGIN_SOURCE_MMO_BROWSERID)
     eq_(tasks._get_monolith_jobs()['mmo_user_count_new'][0]['count'](), 1)
Exemple #10
0
 def test_user_new(self):
     UserProfile.objects.create(username='******',
                                source=amo.LOGIN_SOURCE_MMO_BROWSERID)
     eq_(tasks._get_monolith_jobs()['mmo_user_count_new'][0]['count'](), 1)
Exemple #11
0
 def test_user_new(self):
     UserProfile.objects.create(username="******", source=amo.LOGIN_SOURCE_MMO_BROWSERID)
     eq_(tasks._get_monolith_jobs()["mmo_user_count_new"][0]["count"](), 1)
Exemple #12
0
 def test_app_reviews(self):
     addon = Addon.objects.create(type=amo.ADDON_WEBAPP)
     user = UserProfile.objects.create(username='******')
     Review.objects.create(addon=addon, user=user)
     eq_(tasks._get_monolith_jobs()['apps_review_count_new'][0]['count'](),
         1)
Exemple #13
0
 def test_apps_installed(self):
     addon = Addon.objects.create(type=amo.ADDON_WEBAPP)
     user = UserProfile.objects.create(username='******')
     Installed.objects.create(addon=addon, user=user)
     eq_(tasks._get_monolith_jobs()['apps_count_installed'][0]['count'](),
         1)
Exemple #14
0
 def test_app_new(self):
     Addon.objects.create(type=amo.ADDON_WEBAPP)
     eq_(tasks._get_monolith_jobs()['apps_count_new'][0]['count'](), 1)
Exemple #15
0
 def test_app_new(self):
     Addon.objects.create(type=amo.ADDON_WEBAPP)
     eq_(tasks._get_monolith_jobs()['apps_count_new'][0]['count'](), 1)
Exemple #16
0
 def test_app_reviews(self):
     addon = Addon.objects.create(type=amo.ADDON_WEBAPP)
     user = UserProfile.objects.create(username='******')
     Review.objects.create(addon=addon, user=user)
     eq_(tasks._get_monolith_jobs()['apps_review_count_new'][0]['count'](),
         1)
Exemple #17
0
 def test_apps_installed(self):
     addon = Addon.objects.create(type=amo.ADDON_WEBAPP)
     user = UserProfile.objects.create(username='******')
     Installed.objects.create(addon=addon, user=user)
     eq_(tasks._get_monolith_jobs()['apps_count_installed'][0]['count'](),
         1)