Example #1
0
 def extract_popularity_trending_boost(cls, obj):
     extend = {
         'boost': get_boost(obj),
         'popularity': get_popularity(obj),
         'trending': get_trending(obj)
     }
     for region in mkt.regions.ALL_REGIONS:
         extend['trending_%s' % region.id] = get_trending(obj, region)
         extend['popularity_%s' % region.id] = get_popularity(obj, region)
     return extend
Example #2
0
    def _test_get_trending(self, obj):
        # Test no trending record returns zero.
        eq_(get_trending(obj), 0)

        # Add a region specific trending and test the global one is returned
        # because the region is not mature.
        region = Mock(id=1337, adolescent=True)
        obj.trending.create(value=42.0, region=0)
        obj.trending.create(value=10.0, region=region.id)
        eq_(get_trending(obj, region=region), 42.0)

        # Now test the regional trending is returned when adolescent=False.
        region.adolescent = False
        eq_(get_trending(obj, region=region), 10.0)
Example #3
0
    def test_trending_saved(self, _mock):
        _mock.return_value = {'all': 12.0}
        update_app_trending()

        eq_(get_trending(self.app), 12.0)
        for region in mkt.regions.REGIONS_DICT.values():
            if region.adolescent:
                eq_(get_trending(self.app, region=region), 12.0)
            else:
                eq_(get_trending(self.app, region=region), 0.0)

        # Test running again updates the values as we'd expect.
        _mock.return_value = {'all': 2.0}
        update_app_trending()
        eq_(get_trending(self.app), 2.0)
        for region in mkt.regions.REGIONS_DICT.values():
            if region.adolescent:
                eq_(get_trending(self.app, region=region), 2.0)
            else:
                eq_(get_trending(self.app, region=region), 0.0)
Example #4
0
    def test_trending_saved(self, _mock):
        _mock.return_value = {'all': 12.0}
        update_app_trending()

        eq_(get_trending(self.app), 12.0)
        for region in mkt.regions.REGIONS_DICT.values():
            if region.adolescent:
                eq_(get_trending(self.app, region=region), 12.0)
            else:
                eq_(get_trending(self.app, region=region), 0.0)

        # Test running again updates the values as we'd expect.
        _mock.return_value = {'all': 2.0}
        update_app_trending()
        eq_(get_trending(self.app), 2.0)
        for region in mkt.regions.REGIONS_DICT.values():
            if region.adolescent:
                eq_(get_trending(self.app, region=region), 2.0)
            else:
                eq_(get_trending(self.app, region=region), 0.0)