当前位置: 首页>>代码示例>>Python>>正文


Python OAuthClient.get方法代码示例

本文整理汇总了Python中mkt.api.tests.test_oauth.OAuthClient.get方法的典型用法代码示例。如果您正苦于以下问题:Python OAuthClient.get方法的具体用法?Python OAuthClient.get怎么用?Python OAuthClient.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mkt.api.tests.test_oauth.OAuthClient的用法示例。


在下文中一共展示了OAuthClient.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestApiReviewer

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
class TestApiReviewer(BaseOAuth, ESTestCase):
    fixtures = fixture('webapp_337141', 'user_2519')

    def setUp(self, api_name='apps'):
        self.user = User.objects.get(pk=2519)
        self.profile = self.user.get_profile()
        self.profile.update(read_dev_agreement=datetime.now())
        self.grant_permission(self.profile, 'Apps:Review')

        self.access = Access.objects.create(key='foo', secret=generate(),
                                            user=self.user)
        self.client = OAuthClient(self.access, api_name=api_name)
        self.list_url = ('api_dispatch_list', {'resource_name': 'search'})

        self.webapp = Webapp.objects.get(pk=337141)
        self.category = Category.objects.create(name='test',
                                                type=amo.ADDON_WEBAPP)
        self.webapp.save()
        self.refresh()

    def test_status_reviewer(self):
        res = self.client.get(self.list_url + ({'status': 'public'},))
        eq_(res.status_code, 200)
        obj = json.loads(res.content)['objects'][0]
        eq_(obj['app_slug'], self.webapp.app_slug)

        res = self.client.get(self.list_url + ({'status': 'rejected'},))
        eq_(res.status_code, 200)
        objs = json.loads(res.content)['objects']
        eq_(len(objs), 0)
开发者ID:bsmedberg,项目名称:zamboni,代码行数:32,代码来源:test_api.py

示例2: TestFeaturedHomeHandler

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
class TestFeaturedHomeHandler(BaseOAuth):

    def setUp(self):
        super(TestFeaturedHomeHandler, self).setUp()
        resource = 'featured/home'
        self.list_url = ('api_dispatch_list', {'resource_name': resource})
        self.get_url = None
        self.client = OAuthClient(None)

        self.cat = Category.objects.create(name='awesome',
                                           type=amo.ADDON_WEBAPP)

        # App, no category, worldwide region.
        self.app1 = Webapp.objects.create(status=amo.STATUS_PUBLIC,
                                          name='App 1')
        f1 = FeaturedApp.objects.create(app=self.app1, category=None)
        FeaturedAppRegion.objects.create(featured_app=f1,
                                         region=mkt.regions.WORLDWIDE.id)

        # App, with category, worldwide region. Mostly to ensure category
        # specific featured apps don't slip into the results.
        self.app2 = Webapp.objects.create(status=amo.STATUS_PUBLIC,
                                          name='App 2')
        AddonCategory.objects.create(category=self.cat, addon=self.app2)
        f2 = FeaturedApp.objects.create(app=self.app2, category=self.cat)
        FeaturedAppRegion.objects.create(featured_app=f2,
                                         region=mkt.regions.WORLDWIDE.id)

        # App, no category, US region.
        self.app3 = Webapp.objects.create(status=amo.STATUS_PUBLIC,
                                          name='App 3')
        f3 = FeaturedApp.objects.create(app=self.app3)
        FeaturedAppRegion.objects.create(featured_app=f3,
                                         region=mkt.regions.US.id)

    def test_verbs(self):
        self._allowed_verbs(self.list_url, ['get'])

    def test_get_featured(self):
        res = self.client.get(self.list_url)
        data = json.loads(res.content)
        eq_(res.status_code, 200)
        eq_(data['objects'][0]['app_slug'], self.app1.app_slug)

    def test_get_featured_region(self):
        # UK region should come up empty, so we backfill with worldwide.
        res = self.client.get(self.list_url, data=dict(region='uk'))
        data = json.loads(res.content)
        eq_(res.status_code, 200)
        eq_(data['objects'][0]['app_slug'], self.app1.app_slug)

        # US region should come have 1 plus worldwide.
        res = self.client.get(self.list_url, data=dict(region='us'))
        data = json.loads(res.content)
        eq_(res.status_code, 200)
        self.assertSetEqual([o['app_slug'] for o in data['objects']],
                            ['app-1', 'app-3'])
开发者ID:sandy-slin,项目名称:zamboni,代码行数:59,代码来源:test_handlers.py

示例3: TestCategoryHandler

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
class TestCategoryHandler(BaseOAuth):

    def setUp(self):
        super(TestCategoryHandler, self).setUp()
        self.cat = Category.objects.create(name='Webapp',
                                           type=amo.ADDON_WEBAPP,
                                           slug='thewebapp')
        self.cat.name = {'fr': 'Le Webapp'}
        self.cat.save()
        self.other = Category.objects.create(name='other',
                                             type=amo.ADDON_EXTENSION)

        self.list_url = ('api_dispatch_list', {'resource_name': 'category'})
        self.get_url = ('api_dispatch_detail',
                        {'resource_name': 'category', 'pk': self.cat.pk})

        self.client = OAuthClient(None)

    def test_verbs(self):
        self._allowed_verbs(self.list_url, ['get'])
        self._allowed_verbs(self.get_url, ['get'])

    def test_weight(self):
        self.cat.update(weight=-1)
        res = self.client.get(self.list_url)
        data = json.loads(res.content)
        eq_(data['meta']['total_count'], 0)

    def test_get_categories(self):
        res = self.client.get(self.list_url)
        data = json.loads(res.content)
        eq_(data['meta']['total_count'], 1)
        eq_(data['objects'][0]['name'], 'Webapp')
        eq_(data['objects'][0]['slug'], 'thewebapp')

    def test_get_category(self):
        res = self.client.get(self.get_url)
        data = json.loads(res.content)
        eq_(data['name'], 'Webapp')

    def test_get_category_localised(self):
        res = self.client.get(self.get_url, HTTP_ACCEPT_LANGUAGE='fr')
        data = json.loads(res.content)
        eq_(data['name'], 'Le Webapp')

    def test_get_other_category(self):
        res = self.client.get(('api_dispatch_detail',
                              {'resource_name': 'category',
                               'pk': self.other.pk}))
        eq_(res.status_code, 404)
开发者ID:bsmedberg,项目名称:zamboni,代码行数:52,代码来源:test_handlers.py

示例4: test_owner_still_non_reviewer_access

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
 def test_owner_still_non_reviewer_access(self):
     user = Webapp.objects.get(pk=337141).authors.all()[0].user
     access = Access.objects.create(
         key='test_oauth_key_owner', secret=generate(), user=user)
     client = OAuthClient(access, api_name='reviewers')
     res = client.get(self.url)
     eq_(res.status_code, 401)
开发者ID:markh-bz,项目名称:zamboni,代码行数:9,代码来源:test_api.py

示例5: TestSuggestionsApi

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
class TestSuggestionsApi(ESTestCase):
    fixtures = fixture('webapp_337141')

    def setUp(self):
        self.url = list_url('suggest')
        self.refresh('webapp')
        self.client = OAuthClient(None)

    def test_suggestions(self):
        app1 = Webapp.objects.get(pk=337141)
        app1.save()
        app2 = app_factory(name=u"Second âpp", description=u"Second dèsc" * 25,
                           created=self.days_ago(3))
        self.refresh('webapp')

        response = self.client.get(self.url)
        parsed = json.loads(response.content)
        eq_(parsed[0], '')
        eq_(parsed[1], [unicode(app1.name), unicode(app2.name)])
        eq_(parsed[2], [unicode(app1.description),
                        unicode(truncate(app2.description))])
        eq_(parsed[3], [absolutify(app1.get_detail_url()),
                        absolutify(app2.get_detail_url())])
        eq_(parsed[4], [app1.get_icon_url(64), app2.get_icon_url(64)])

        # Cleanup to remove these from the index.
        unindex_webapps([app1.id, app2.id])
        app1.delete()
        app2.delete()
开发者ID:at13,项目名称:zamboni,代码行数:31,代码来源:test_api.py

示例6: test_admin_get

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
 def test_admin_get(self):
     self.create_app()
     admin = UserProfile.objects.get(email="[email protected]ozilla.com")
     g = Group.objects.create(rules="*:*")
     GroupUser.objects.create(group=g, user=admin)
     ac = Access.objects.create(key="adminOauthKey", secret=generate(), user=admin.user)
     client = OAuthClient(ac, api_name="apps")
     r = client.get(self.get_url)
     eq_(r.status_code, 200)
开发者ID:kmaglione,项目名称:zamboni,代码行数:11,代码来源:test_handlers.py

示例7: test_reviewer_get

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
 def test_reviewer_get(self):
     self.create_app()
     editor = UserProfile.objects.get(email="[email protected]")
     g = Group.objects.create(rules="Apps:Review,Reviews:Edit")
     GroupUser.objects.create(group=g, user=editor)
     ac = Access.objects.create(key="adminOauthKey", secret=generate(), user=editor.user)
     client = OAuthClient(ac, api_name="apps")
     r = client.get(self.get_url)
     eq_(r.status_code, 200)
开发者ID:kmaglione,项目名称:zamboni,代码行数:11,代码来源:test_handlers.py

示例8: TestCategoryHandler

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
class TestCategoryHandler(BaseOAuth):
    def setUp(self):
        super(TestCategoryHandler, self).setUp()
        self.cat = Category.objects.create(name="Webapp", type=amo.ADDON_WEBAPP, slug="thewebapp")
        self.cat.name = {"fr": "Le Webapp"}
        self.cat.save()
        self.other = Category.objects.create(name="other", type=amo.ADDON_EXTENSION)

        self.list_url = ("api_dispatch_list", {"resource_name": "category"})
        self.get_url = ("api_dispatch_detail", {"resource_name": "category", "pk": self.cat.pk})

        self.client = OAuthClient(None)

    def test_verbs(self):
        self._allowed_verbs(self.list_url, ["get"])
        self._allowed_verbs(self.get_url, ["get"])

    def test_weight(self):
        self.cat.update(weight=-1)
        res = self.client.get(self.list_url)
        data = json.loads(res.content)
        eq_(data["meta"]["total_count"], 0)

    def test_get_categories(self):
        res = self.client.get(self.list_url)
        data = json.loads(res.content)
        eq_(data["meta"]["total_count"], 1)
        eq_(data["objects"][0]["name"], "Webapp")
        eq_(data["objects"][0]["slug"], "thewebapp")

    def test_get_category(self):
        res = self.client.get(self.get_url)
        data = json.loads(res.content)
        eq_(data["name"], "Webapp")

    def test_get_category_localised(self):
        res = self.client.get(self.get_url, HTTP_ACCEPT_LANGUAGE="fr")
        data = json.loads(res.content)
        eq_(data["name"], "Le Webapp")

    def test_get_other_category(self):
        res = self.client.get(("api_dispatch_detail", {"resource_name": "category", "pk": self.other.pk}))
        eq_(res.status_code, 404)
开发者ID:almet,项目名称:zamboni,代码行数:45,代码来源:test_handlers.py

示例9: TestApiFlags

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
class TestApiFlags(BaseOAuth, ESTestCase):
    fixtures = fixture('webapp_337141')
    url = list_url('search')

    def setUp(self):
        self.create_switch('search-api-es')
        self.client = OAuthClient(None)
        self.webapp = Webapp.objects.get(pk=337141)

    def _flag(self, adult=False, child=False):
        Flag.objects.create(addon=self.webapp, adult_content=adult,
                            child_content=child)
        self.webapp.save()
        self.refresh('webapp')

    def test_no_flags(self):
        self.webapp.save()
        self.refresh('webapp')
        res = self.client.get(self.url + ({'q': 'something'},))
        eq_(res.status_code, 200)
        obj = json.loads(res.content)['objects'][0]
        eq_(obj['slug'], self.webapp.app_slug)

    def test_adult(self):
        self._flag(adult=True)
        res = self.client.get(self.url + (
            {'q': 'something',
             'region': list(mkt.regions.ADULT_EXCLUDED)[0].slug},))
        eq_(res.status_code, 200)
        objs = json.loads(res.content)['objects']
        eq_(len(objs), 0, 'App with adult_content not removed from search.')

    def test_child(self):
        self._flag(child=True)
        res = self.client.get(self.url + (
            {'q': 'something',
             'region': list(mkt.regions.CHILD_EXCLUDED)[0].slug},))
        eq_(res.status_code, 200)
        objs = json.loads(res.content)['objects']
        eq_(len(objs), 0, 'App with child_content not removed from search.')
开发者ID:mitramichaeljade,项目名称:zamboni,代码行数:42,代码来源:test_api.py

示例10: TestAccount

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
class TestAccount(BaseOAuth):
    fixtures = fixture('user_2519', 'user_10482', 'webapp_337141')

    def setUp(self):
        super(TestAccount, self).setUp()
        self.list_url = list_url('account')
        self.get_url = get_url('account', '2519')
        self.anon = OAuthClient(None, api_name='apps')
        self.user = UserProfile.objects.get(pk=2519)

    def test_verbs(self):
        self._allowed_verbs(self.list_url, ())
        self._allowed_verbs(self.get_url, ('get',))

    def test_not_allowed(self):
        eq_(self.anon.get(self.get_url).status_code, 401)

    def test_allowed(self):
        res = self.client.get(self.get_url)
        eq_(res.status_code, 200, res.content)
        data = json.loads(res.content)
        eq_(data['display_name'], self.user.display_name)
        eq_(data['installed'], [])

    def test_install(self):
        ins = Installed.objects.create(user=self.user, addon_id=337141)
        res = self.client.get(self.get_url)
        eq_(res.status_code, 200, res.content)
        data = json.loads(res.content)
        eq_(data['installed'],
            [get_absolute_url(get_url('app', ins.addon.pk), absolute=False)])

    def test_install_reviewer(self):
        Installed.objects.create(user=self.user, addon_id=337141,
                                 install_type=INSTALL_TYPE_REVIEWER)
        res = self.client.get(self.get_url)
        eq_(res.status_code, 200, res.content)
        data = json.loads(res.content)
        eq_(data['installed'], [])

    def test_other(self):
        eq_(self.client.get(get_url('account', '10482')).status_code, 403)

    def test_own(self):
        res = self.client.get(get_url('account', 'mine'))
        eq_(res.status_code, 200)
        data = json.loads(res.content)
        eq_(data['display_name'], self.user.display_name)
开发者ID:almet,项目名称:zamboni,代码行数:50,代码来源:test_api.py

示例11: TestAccount

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
class TestAccount(BaseOAuth):
    fixtures = fixture('user_2519', 'webapp_337141')

    def setUp(self):
        super(TestAccount, self).setUp(api_name='reviewers')
        self.list_url = list_url('reviewing')
        self.anon = OAuthClient(None, api_name='reviewers')
        self.user = UserProfile.objects.get(pk=2519)
        self.req = RequestFactory().get('/')
        self.req.amo_user = self.user

    def test_verbs(self):
        self._allowed_verbs(self.list_url, ('get'))

    def test_not_allowed(self):
        eq_(self.anon.get(self.list_url).status_code, 401)

    def test_still_not_allowed(self):
        eq_(self.client.get(self.list_url).status_code, 401)

    def add_perms(self):
        self.grant_permission(self.user, 'Apps:Review')

    def test_allowed(self):
        self.add_perms()
        res = self.client.get(self.list_url)
        eq_(res.status_code, 200, res.content)
        data = json.loads(res.content)
        eq_(data['objects'], [])

    def test_some(self):
        self.add_perms()

        # This feels rather brittle.
        cache.set('%s:review_viewing:%s' % (settings.CACHE_PREFIX, 337141),
                  2519, 50 * 2)
        AppsReviewing(self.req).add(337141)

        res = self.client.get(self.list_url)
        data = json.loads(res.content)
        eq_(data['objects'][0]['resource_uri'],
            get_absolute_url(get_url('app', '337141'), absolute=False))
开发者ID:chenzihui,项目名称:zamboni,代码行数:44,代码来源:test_api.py

示例12: TestApiReviewer

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
class TestApiReviewer(BaseOAuth, ESTestCase):
    fixtures = fixture("webapp_337141", "user_2519")

    def setUp(self, api_name="apps"):
        self.user = User.objects.get(pk=2519)
        self.profile = self.user.get_profile()
        self.profile.update(read_dev_agreement=datetime.now())
        self.grant_permission(self.profile, "Apps:Review")

        self.access = Access.objects.create(key="foo", secret=generate(), user=self.user)
        self.client = OAuthClient(self.access, api_name=api_name)
        self.list_url = ("api_dispatch_list", {"resource_name": "search"})

        self.webapp = Webapp.objects.get(pk=337141)
        self.category = Category.objects.create(name="test", type=amo.ADDON_WEBAPP)
        self.webapp.save()
        self.refresh()

    def test_status_reviewer(self):
        res = self.client.get(self.list_url + ({"status": "public"},))
        eq_(res.status_code, 200)
        obj = json.loads(res.content)["objects"][0]
        eq_(obj["app_slug"], self.webapp.app_slug)

        res = self.client.get(self.list_url + ({"status": "rejected"},))
        eq_(res.status_code, 200)
        objs = json.loads(res.content)["objects"]
        eq_(len(objs), 0)

        res = self.client.get(self.list_url + ({"status": "vindaloo"},))
        eq_(res.status_code, 400)
        error = json.loads(res.content)["error_message"]
        eq_(error.keys(), ["status"])

    def test_addon_type_reviewer(self):
        res = self.client.get(self.list_url + ({"type": "app"},))
        eq_(res.status_code, 200)
        obj = json.loads(res.content)["objects"][0]
        eq_(obj["app_slug"], self.webapp.app_slug)

        res = self.client.get(self.list_url + ({"type": "persona"},))
        eq_(res.status_code, 200)
        objs = json.loads(res.content)["objects"]
        eq_(len(objs), 0)

        res = self.client.get(self.list_url + ({"type": "vindaloo"},))
        eq_(res.status_code, 400)
        error = json.loads(res.content)["error_message"]
        eq_(error.keys(), ["type"])
开发者ID:almet,项目名称:zamboni,代码行数:51,代码来源:test_api.py

示例13: TestDeviceTypeHandler

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
class TestDeviceTypeHandler(BaseOAuth):

    def setUp(self):
        super(TestDeviceTypeHandler, self).setUp()

        self.dt = DeviceType.objects.create(name='Phone')
        self.dt.name = {'fr': 'Le phone'}
        self.dt.save()
        self.list_url = ('api_dispatch_list', {'resource_name': 'devicetype'})
        self.get_url = ('api_dispatch_detail',
                        {'resource_name': 'devicetype', 'pk': self.dt.pk})

        self.client = OAuthClient(None)

    def test_verbs(self):
        self._allowed_verbs(self.list_url, ['get'])
        self._allowed_verbs(self.get_url, ['get'])

    def test_get_devicetypes(self):
        res = self.client.get(self.list_url)
        data = json.loads(res.content)
        eq_(data['meta']['total_count'], 1)
        eq_(data['objects'][0]['name'], 'phone')
开发者ID:ominds,项目名称:zamboni,代码行数:25,代码来源:test_handlers.py

示例14: TestApiReviewer

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
class TestApiReviewer(BaseOAuth, ESTestCase):
    fixtures = fixture("webapp_337141", "user_2519")

    def setUp(self, api_name="apps"):
        self.create_switch("search-api-es")
        self.user = User.objects.get(pk=2519)
        self.profile = self.user.get_profile()
        self.profile.update(read_dev_agreement=datetime.now())
        self.grant_permission(self.profile, "Apps:Review")

        self.access = Access.objects.create(key="test_oauth_key", secret=generate(), user=self.user)
        self.client = OAuthClient(self.access, api_name=api_name)
        self.url = list_url("search")

        self.webapp = Webapp.objects.get(pk=337141)
        self.category = Category.objects.create(name="test", type=amo.ADDON_WEBAPP)
        self.webapp.save()
        self.refresh("webapp")

    def test_status_reviewer(self):
        res = self.client.get(self.url + ({"status": "public"},))
        eq_(res.status_code, 200)
        obj = res.json["objects"][0]
        eq_(obj["slug"], self.webapp.app_slug)

        res = self.client.get(self.url + ({"status": "rejected"},))
        eq_(res.status_code, 200)
        objs = res.json["objects"]
        eq_(len(objs), 0)

        res = self.client.get(self.url + ({"status": "any"},))
        eq_(res.status_code, 200)
        obj = res.json["objects"][0]
        eq_(obj["slug"], self.webapp.app_slug)

        res = self.client.get(self.url + ({"status": "vindaloo"},))
        eq_(res.status_code, 400)
        error = res.json["error_message"]
        eq_(error.keys(), ["status"])

    def test_status_value_packaged(self):
        # When packaged we also include the latest version status.
        self.webapp.update(is_packaged=True)
        res = self.client.get(self.url)
        eq_(res.status_code, 200)
        obj = res.json["objects"][0]
        eq_(obj["status"], amo.STATUS_PUBLIC)
        eq_(obj["latest_version_status"], amo.STATUS_PUBLIC)

    def test_addon_type_reviewer(self):
        res = self.client.get(self.url + ({"type": "app"},))
        eq_(res.status_code, 200)
        obj = res.json["objects"][0]
        eq_(obj["slug"], self.webapp.app_slug)

        res = self.client.get(self.url + ({"type": "theme"},))
        eq_(res.status_code, 200)
        objs = res.json["objects"]
        eq_(len(objs), 0)

        res = self.client.get(self.url + ({"type": "vindaloo"},))
        eq_(res.status_code, 400)
        error = res.json["error_message"]
        eq_(error.keys(), ["type"])

    def test_extra_attributes(self):
        version = self.webapp.versions.latest()
        version.has_editor_comment = True
        version.has_info_request = True
        version.save()

        res = self.client.get(self.url)
        eq_(res.status_code, 200)
        obj = res.json["objects"][0]

        # These only exist if requested by a reviewer.
        eq_(obj["latest_version_status"], amo.STATUS_PUBLIC)
        eq_(obj["reviewer_flags"]["has_comment"], True)
        eq_(obj["reviewer_flags"]["has_info_request"], True)
        eq_(obj["reviewer_flags"]["is_escalated"], False)

    def test_extra_attributes_no_waffle(self):
        # Make sure these still exist when 'search-api-es' is off.
        # TODO: Remove this test when we remove that switch.
        Switch.objects.all().delete()
        version = self.webapp.versions.latest()
        version.has_editor_comment = True
        version.has_info_request = True
        version.save()

        res = self.client.get(self.url)
        eq_(res.status_code, 200)
        obj = res.json["objects"][0]

        # These only exist if requested by a reviewer.
        eq_(obj["latest_version_status"], amo.STATUS_PUBLIC)
        eq_(obj["reviewer_flags"]["has_comment"], True)
        eq_(obj["reviewer_flags"]["has_info_request"], True)
        eq_(obj["reviewer_flags"]["is_escalated"], False)
开发者ID:wraithan,项目名称:zamboni,代码行数:101,代码来源:test_api.py

示例15: TestApiFeatures

# 需要导入模块: from mkt.api.tests.test_oauth import OAuthClient [as 别名]
# 或者: from mkt.api.tests.test_oauth.OAuthClient import get [as 别名]
class TestApiFeatures(BaseOAuth, ESTestCase):
    fixtures = fixture("webapp_337141")

    def setUp(self):
        self.create_switch("search-api-es")
        self.create_switch("buchets")
        self.client = OAuthClient(None)
        self.url = list_url("search")
        self.webapp = Webapp.objects.get(pk=337141)
        self.category = Category.objects.create(name="test", type=amo.ADDON_WEBAPP)
        # Pick a few common device features.
        self.profile = FeatureProfile(
            apps=True, audio=True, fullscreen=True, geolocation=True, indexeddb=True, sms=True
        ).to_signature()
        self.qs = {"q": "something", "pro": self.profile, "dev": "firefoxos"}

    def test_no_features(self):
        # Base test to make sure we find the app.
        self.webapp.save()
        self.refresh("webapp")

        res = self.client.get(self.url + (self.qs,))
        eq_(res.status_code, 200)
        obj = json.loads(res.content)["objects"][0]
        eq_(obj["slug"], self.webapp.app_slug)

    def test_one_good_feature(self):
        # Enable an app feature that matches one in our profile.
        self.webapp.current_version.features.update(has_geolocation=True)
        self.webapp.save()
        self.refresh("webapp")

        res = self.client.get(self.url + (self.qs,))
        eq_(res.status_code, 200)
        obj = json.loads(res.content)["objects"][0]
        eq_(obj["slug"], self.webapp.app_slug)

    def test_one_bad_feature(self):
        # Enable an app feature that doesn't match one in our profile.
        self.webapp.current_version.features.update(has_pay=True)
        self.webapp.save()
        self.refresh("webapp")

        res = self.client.get(self.url + (self.qs,))
        eq_(res.status_code, 200)
        objs = json.loads(res.content)["objects"]
        eq_(len(objs), 0)

    def test_all_good_features(self):
        # Enable app features so they exactly match our device profile.
        fp = FeatureProfile.from_signature(self.profile)
        self.webapp.current_version.features.update(**dict(("has_%s" % k, v) for k, v in fp.items()))
        self.webapp.save()
        self.refresh("webapp")

        res = self.client.get(self.url + (self.qs,))
        eq_(res.status_code, 200)
        obj = json.loads(res.content)["objects"][0]
        eq_(obj["slug"], self.webapp.app_slug)

    def test_bad_profile_on_desktop(self):
        # Enable an app feature that doesn't match one in our profile.
        qs = self.qs.copy()
        del qs["dev"]  # Desktop doesn't send a device.
        self.webapp.current_version.features.update(has_pay=True)
        self.webapp.save()
        self.refresh("webapp")

        res = self.client.get(self.url + (qs,))
        eq_(res.status_code, 200)
        obj = json.loads(res.content)["objects"][0]
        eq_(obj["slug"], self.webapp.app_slug)
开发者ID:wraithan,项目名称:zamboni,代码行数:74,代码来源:test_api.py


注:本文中的mkt.api.tests.test_oauth.OAuthClient.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。