Beispiel #1
0
    def setUp(self):
        super(TestFlaggedUsersPremiumApps, self).setUp()
        self.req = test_utils.RequestFactory().get('/')
        self.req.user = self.user = UserProfile.objects.get(pk=2519).user
        self.flag = Flag.objects.create(name='allow-paid-app-search')

        # Pick a region that has relatively few filters.
        set_region(regions.UK.slug)

        self.filter_kwargs = {
            'mobile': False,
            'gaia': False,
            'tablet': False,
        }

        self.query_string = {
            'dev': 'android',
            'device': 'mobile',
        }

        self.prem_exclude = {
            'not': {
                'filter': {
                    'and': [
                        {'range': {'price': {'gt': 0}}},
                        {'in': {'premium_type': (1, 2)}}]}}}
Beispiel #2
0
    def setUp(self):
        super(TestSearchFilters, self).setUp()
        self.req = test_utils.RequestFactory().get("/")
        self.req.user = AnonymousUser()

        self.category = Category.objects.create(name="games", type=amo.ADDON_WEBAPP)
        # Pick a region that has relatively few filters.
        set_region(regions.UK.slug)
Beispiel #3
0
    def setUp(self):
        super(TestSearchFilters, self).setUp()
        self.req = test_utils.RequestFactory().get('/')
        self.req.user = AnonymousUser()

        # Pick a region that has relatively few filters.
        set_region(regions.UK.slug)

        self.form_class = ApiSearchForm
Beispiel #4
0
    def setUp(self):
        super(TestSearchFilters, self).setUp()
        self.req = test_utils.RequestFactory().get('/')
        self.req.user = AnonymousUser()

        # Pick a region that has relatively few filters.
        set_region(regions.UK.slug)

        self.form_class = ApiSearchForm
Beispiel #5
0
    def setUp(self):
        super(TestSearchFilters, self).setUp()
        self.req = test_utils.RequestFactory().get('/')
        self.req.user = AnonymousUser()

        self.category = Category.objects.create(name='games',
                                                type=amo.ADDON_WEBAPP)
        # Pick a region that has relatively few filters.
        set_region(regions.UK.slug)
Beispiel #6
0
    def setUp(self):
        super(TestSearchFiltersAndroid, self).setUp()
        self.req = test_utils.RequestFactory().get("/")
        self.req.user = AnonymousUser()

        self.category = Category.objects.create(name="games", type=amo.ADDON_WEBAPP)
        # Pick a region that has relatively few filters.
        set_region(regions.UK.slug)

        self.filter_kwargs = {"mobile": True, "gaia": False, "tablet": False}

        self.query_string = {"dev": "android", "device": "mobile"}
Beispiel #7
0
    def test_region(self):
        # Test regions that affect search filters.

        # Test region with no filters.
        qs = self._filter(self.req, {'q': 'yolo'})
        qs_str = json.dumps(qs)
        ok_('not' not in qs_str)

        # Test child-excluded region.
        set_region(list(regions.CHILD_EXCLUDED)[0].slug)
        qs = self._filter(self.req, {'q': 'yolo'})
        eq_(qs['filter']['not'], {'filter': {'term': {'flag_child': True}}})

        # Test adult-excluded region.
        set_region(list(regions.ADULT_EXCLUDED)[0].slug)
        qs = self._filter(self.req, {'q': 'yolo'})
        eq_(qs['filter']['not'], {'filter': {'term': {'flag_adult': True}}})
Beispiel #8
0
    def setUp(self):
        super(TestSearchFiltersAndroid, self).setUp()
        self.req = test_utils.RequestFactory().get('/')
        self.req.user = AnonymousUser()

        self.category = Category.objects.create(name='games',
                                                type=amo.ADDON_WEBAPP)
        # Pick a region that has relatively few filters.
        set_region(regions.UK.slug)

        self.filter_kwargs = {
            'mobile': True,
            'gaia': False,
            'tablet': False,
        }

        self.query_string = {
            'dev': 'android',
            'device': 'mobile',
        }
Beispiel #9
0
def test_set_region_bad_slug():
    set_region('foo')
    eq_(get_region(), regions.RESTOFWORLD)
Beispiel #10
0
def test_set_region_object():
    set_region(regions.US)
    eq_(get_region(), regions.US)
    set_region(regions.SPAIN)
    eq_(get_region(), regions.SPAIN)
Beispiel #11
0
def test_set_region(local):
    local.region = 'us'

    eq_(get_region(), regions.US)
    set_region('es')
    eq_(get_region(), regions.SPAIN)
Beispiel #12
0
def test_set_region(local):
    local.region = 'us'

    eq_(get_region(), 'us')
    set_region('es')
    eq_(get_region(), 'es')
Beispiel #13
0
def test_set_region(local):
    local.region = 'us'

    eq_(get_region(), 'us')
    set_region('es')
    eq_(get_region(), 'es')
Beispiel #14
0
def test_set_region_object():
    set_region(regions.USA)
    eq_(get_region(), regions.USA)
    set_region(regions.ESP)
    eq_(get_region(), regions.ESP)
Beispiel #15
0
def test_set_region(local):
    local.region = 'us'

    eq_(get_region(), regions.USA)
    set_region('es')
    eq_(get_region(), regions.ESP)