• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python test_oauth.RestOAuthClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_owner_still_non_reviewer_access

 def test_owner_still_non_reviewer_access(self):
     user = Webapp.objects.get(pk=337141).authors.all()[0]
     access = Access.objects.create(
         key='test_oauth_key_owner', secret='super secret', user=user)
     client = RestOAuthClient(access)
     res = client.get(self.url)
     eq_(res.status_code, 403)
开发者ID:Witia1,项目名称:zamboni,代码行数:7,代码来源:test_views_api.py


示例2: TestSuggestionsApi

class TestSuggestionsApi(ESTestCase):
    fixtures = fixture("webapp_337141")

    def setUp(self):
        self.url = reverse("suggestions-search-api")
        self.refresh("webapp")
        self.client = RestOAuthClient(None)
        self.app1 = Webapp.objects.get(pk=337141)
        self.app1.save()
        self.app2 = app_factory(
            name=u"Second âpp", description=u"Second dèsc" * 25, icon_type="image/png", created=self.days_ago(3)
        )
        self.refresh("webapp")

    def tearDown(self):
        # Cleanup to remove these from the index.
        unindex_webapps([self.app1.id, self.app2.id])
        self.app1.delete()
        self.app2.delete()

    def test_suggestions(self):
        response = self.client.get(self.url, data={"lang": "en-US"})
        parsed = json.loads(response.content)
        eq_(parsed[0], "")
        self.assertSetEqual(parsed[1], [unicode(self.app1.name), unicode(self.app2.name)])
        self.assertSetEqual(parsed[2], [unicode(self.app1.description), unicode(truncate(self.app2.description))])
        self.assertSetEqual(parsed[3], [absolutify(self.app1.get_detail_url()), absolutify(self.app2.get_detail_url())])
        self.assertSetEqual(parsed[4], [self.app1.get_icon_url(64), self.app2.get_icon_url(64)])

    def test_suggestions_filtered(self):
        response = self.client.get(self.url, data={"q": "Second", "lang": "en-US"})
        parsed = json.loads(response.content)
        eq_(parsed[1], [unicode(self.app2.name)])
开发者ID:vinu76jsr,项目名称:zamboni,代码行数:33,代码来源:test_api.py


示例3: test_admin_get

 def test_admin_get(self):
     self.create_app()
     admin = UserProfile.objects.get(email="[email protected]")
     g = Group.objects.create(rules="*:*")
     GroupUser.objects.create(group=g, user=admin)
     ac = Access.objects.create(key="adminOauthKey", secret=generate(), user=admin.user)
     client = RestOAuthClient(ac)
     r = client.get(self.get_url)
     eq_(r.status_code, 200)
开发者ID:hardikj,项目名称:zamboni,代码行数:9,代码来源:test_handlers.py


示例4: test_reviewer_get

 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 = RestOAuthClient(ac)
     r = client.get(self.get_url)
     eq_(r.status_code, 200)
开发者ID:hardikj,项目名称:zamboni,代码行数:9,代码来源:test_handlers.py


示例5: setUp

 def setUp(self):
     self.client = RestOAuthClient(None)
     self.url = reverse("search-api")
     self.webapp = Webapp.objects.get(pk=337141)
     self.category = Category.objects.create(name="test", slug="test", type=amo.ADDON_WEBAPP)
     self.webapp.save()
     self.refresh("webapp")
开发者ID:vinu76jsr,项目名称:zamboni,代码行数:7,代码来源:test_api.py


示例6: test_admin_get

    def test_admin_get(self):
        app = self.create_app()
        data = self.base_data()
        self.client.put(self.get_url, data=json.dumps(data))

        admin = UserProfile.objects.get(email="[email protected]")
        g = Group.objects.create(rules="*:*")
        GroupUser.objects.create(group=g, user=admin)
        ac = Access.objects.create(key="adminOauthKey", secret=generate(), user=admin)
        client = RestOAuthClient(ac)
        r = client.get(self.get_url)
        eq_(r.status_code, 200)

        res = client.get(reverse("app-privacy-policy-detail", args=[app.pk]))
        eq_(r.status_code, 200)
        eq_(res.json["privacy_policy"], data["privacy_policy"])
开发者ID:kylewu,项目名称:zamboni,代码行数:16,代码来源:test_handlers.py


示例7: TestRocketbarApi

class TestRocketbarApi(ESTestCase):
    fixtures = fixture('webapp_337141')

    def setUp(self):
        self.url = reverse('rocketbar-search-api')
        self.refresh('webapp')
        self.client = RestOAuthClient(None)
        self.app1 = Webapp.objects.get(pk=337141)
        self.app1.save()
        self.app2 = app_factory(name=u'Second âpp',
                                description=u'Second dèsc' * 25,
                                icon_type='image/png',
                                created=self.days_ago(3),
                                manifest_url='http://testrocketbar.example.com')
        self.refresh('webapp')

    def tearDown(self):
        # Cleanup to remove these from the index.
        unindex_webapps([self.app1.id, self.app2.id])
        self.app1.delete()
        self.app2.delete()

    def test_suggestions_filtered(self):
        response = self.client.get(self.url, data={'q': 'Second',
                                                   'lang': 'en-US'})
        parsed = json.loads(response.content)
        eq_(parsed, [{'manifest_url': self.app2.get_manifest_url(),
                      'icon': self.app2.get_icon_url(64),
                      'name': unicode(self.app2.name),
                      'slug': self.app2.app_slug}])
开发者ID:bdacode,项目名称:zamboni,代码行数:30,代码来源:test_api.py


示例8: test_admin_get

    def test_admin_get(self):
        app = self.create_app(privacy_policy=u'élolà')

        admin = UserProfile.objects.get(email='[email protected]')
        g = Group.objects.create(rules='*:*')
        GroupUser.objects.create(group=g, user=admin)
        ac = Access.objects.create(key='adminOauthKey', secret='admin secret',
                                   user=admin)
        client = RestOAuthClient(ac)
        r = client.get(self.get_url)
        eq_(r.status_code, 200)

        res = client.get(reverse('app-privacy-policy-detail',
                                 args=[app.pk]))
        eq_(r.status_code, 200)
        eq_(res.json['privacy_policy'], u'élolà')
开发者ID:jasonthomas,项目名称:zamboni,代码行数:16,代码来源:test_handlers.py


示例9: setUp

 def setUp(self):
     self.client = RestOAuthClient(None)
     self.url = reverse('search-api')
     self.webapp = Webapp.objects.get(pk=337141)
     self.category = 'books'
     self.webapp.icon_hash = 'fakehash'
     self.webapp.save()
     self.refresh('webapp')
开发者ID:andymckay,项目名称:zamboni,代码行数:8,代码来源:test_views.py


示例10: test_reviewer_get

    def test_reviewer_get(self):
        app = self.create_app()
        data = self.base_data()
        self.client.put(self.get_url, data=json.dumps(data))

        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 = RestOAuthClient(ac)
        r = client.get(self.get_url)
        eq_(r.status_code, 200)

        res = client.get(reverse('app-privacy-policy-detail',
                                 args=[app.pk]))
        eq_(r.status_code, 200)
        eq_(res.json['privacy_policy'], data['privacy_policy'])
开发者ID:BIGGANI,项目名称:zamboni,代码行数:18,代码来源:test_handlers.py


示例11: setUp

 def setUp(self):
     self.client = RestOAuthClient(None)
     self.url = reverse('search-api')
     self.webapp = Webapp.objects.get(pk=337141)
     # 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'}
开发者ID:Dreadchild,项目名称:zamboni,代码行数:9,代码来源:test_views.py


示例12: TestSuggestionsApi

class TestSuggestionsApi(ESTestCase):
    fixtures = fixture('webapp_337141')

    def setUp(self):
        self.url = reverse('suggestions-api')
        self.refresh('webapp')
        self.client = RestOAuthClient(None)
        self.app1 = Webapp.objects.get(pk=337141)
        self.app1.save()
        self.app2 = app_factory(name=u'Second âpp',
                                description=u'Second dèsc' * 25,
                                created=self.days_ago(3))
        self.refresh('webapp')

    def tearDown(self):
        # Cleanup to remove these from the index.
        unindex_webapps([self.app1.id, self.app2.id])
        self.app1.delete()
        self.app2.delete()

    def test_suggestions(self):
        response = self.client.get(self.url, data={'lang': 'en-US'})
        parsed = json.loads(response.content)
        eq_(parsed[0], '')
        self.assertSetEqual(
            parsed[1],
            [unicode(self.app1.name), unicode(self.app2.name)])
        self.assertSetEqual(
            parsed[2],
            [unicode(self.app1.description),
             unicode(truncate(self.app2.description))])
        self.assertSetEqual(
            parsed[3],
            [absolutify(self.app1.get_detail_url()),
             absolutify(self.app2.get_detail_url())])
        self.assertSetEqual(
            parsed[4],
            [self.app1.get_icon_url(64), self.app2.get_icon_url(64)])

    def test_suggestions_filtered(self):
        response = self.client.get(self.url, data={'q': 'Second',
                                                   'lang': 'en-US'})
        parsed = json.loads(response.content)
        eq_(parsed[1], [unicode(self.app2.name)])
开发者ID:hardikj,项目名称:zamboni,代码行数:44,代码来源:test_api.py


示例13: setUp

 def setUp(self):
     self.url = reverse('suggestions-api')
     self.refresh('webapp')
     self.client = RestOAuthClient(None)
     self.app1 = Webapp.objects.get(pk=337141)
     self.app1.save()
     self.app2 = app_factory(name=u'Second âpp',
                             description=u'Second dèsc' * 25,
                             created=self.days_ago(3))
     self.refresh('webapp')
开发者ID:hardikj,项目名称:zamboni,代码行数:10,代码来源:test_api.py


示例14: setUp

 def setUp(self):
     self.url = reverse('rocketbar-search-api')
     self.refresh('webapp')
     self.client = RestOAuthClient(None)
     self.app1 = Webapp.objects.get(pk=337141)
     self.app1.save()
     self.app2 = app_factory(name=u'Second âpp',
                             description=u'Second dèsc' * 25,
                             icon_type='image/png',
                             created=self.days_ago(3),
                             manifest_url='http://testrocketbar.example.com')
     self.refresh('webapp')
开发者ID:bdacode,项目名称:zamboni,代码行数:12,代码来源:test_api.py


示例15: setUp

 def setUp(self):
     self.client = RestOAuthClient(None)
     self.url = reverse('search-api')
     self.webapp = Webapp.objects.get(pk=337141)
     self.webapp.platform_set.create(platform_id=mkt.PLATFORM_FXOS.id)
     self.webapp.form_factor_set.create(form_factor_id=mkt.FORM_MOBILE.id)
     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,
                'platform': 'firefoxos', 'form_factor': 'mobile'}
开发者ID:unghost,项目名称:zamboni,代码行数:14,代码来源:test_api.py


示例16: setUp

    def setUp(self):
        self.url = reverse('rocketbar-search-api')
        self.refresh('webapp')
        self.client = RestOAuthClient(None)
        self.app1 = Webapp.objects.get(pk=337141)
        self.app1.addondevicetype_set.create(device_type=amo.DEVICE_GAIA.id)
        self.app1.save()

        self.app2 = app_factory(name=u'Something Second Something Something',
                                description=u'Second dèsc' * 25,
                                icon_type='image/png',
                                created=self.days_ago(3),
                                manifest_url='http://rocket.example.com')
        self.app2.addondevicetype_set.create(device_type=amo.DEVICE_GAIA.id)
        self.app2.save()
        self.refresh('webapp')
开发者ID:AALEKH,项目名称:zamboni,代码行数:16,代码来源:test_api.py


示例17: setUp

    def setUp(self):
        self.url = reverse("rocketbar-search-api")
        self.refresh("webapp")
        self.client = RestOAuthClient(None)
        self.app1 = Webapp.objects.get(pk=337141)
        self.app1.addondevicetype_set.create(device_type=amo.DEVICE_GAIA.id)
        self.app1.save()

        self.app2 = app_factory(
            name=u"Something Second Something Something",
            description=u"Second dèsc" * 25,
            icon_type="image/png",
            icon_hash="fakehash",
            created=self.days_ago(3),
            manifest_url="http://rocket.example.com",
        )
        self.app2.addondevicetype_set.create(device_type=amo.DEVICE_GAIA.id)
        self.app2.save()
        self.refresh("webapp")
开发者ID:nearlyfreeapps,项目名称:zamboni,代码行数:19,代码来源:test_api.py


示例18: setUp

    def setUp(self):
        self.url = reverse('rocketbar-search-api')
        self.refresh('webapp')
        self.client = RestOAuthClient(None)
        self.profile = UserProfile.objects.get(pk=2519)
        self.app1 = Webapp.objects.get(pk=337141)
        self.app1.addondevicetype_set.create(device_type=amo.DEVICE_GAIA.id)
        self.app1.save()

        self.app2 = app_factory(name=u'Something Second Something Something',
                                description=u'Second dèsc' * 25,
                                icon_type='image/png',
                                icon_hash='fakehash',
                                created=self.days_ago(3),
                                manifest_url='http://rocket.example.com')
        self.app2.addondevicetype_set.create(device_type=amo.DEVICE_GAIA.id)
        # Add 2 installed records so this app is boosted higher than app1.
        Installed.objects.create(user=self.profile, addon=self.app2)
        Installed.objects.create(user=self.profile, addon=self.app2)
        self.app2.save()
        self.refresh('webapp')
开发者ID:lissyx,项目名称:zamboni,代码行数:21,代码来源:test_api.py


示例19: TestRocketbarApi

class TestRocketbarApi(ESTestCase):
    fixtures = fixture("webapp_337141")

    def setUp(self):
        self.url = reverse("rocketbar-search-api")
        self.refresh("webapp")
        self.client = RestOAuthClient(None)
        self.app1 = Webapp.objects.get(pk=337141)
        self.app1.save()
        self.app2 = app_factory(
            name=u"Second âpp",
            description=u"Second dèsc" * 25,
            icon_type="image/png",
            created=self.days_ago(3),
            manifest_url="http://testrocketbar.example.com",
        )
        self.refresh("webapp")

    def tearDown(self):
        # Cleanup to remove these from the index.
        unindex_webapps([self.app1.id, self.app2.id])
        self.app1.delete()
        self.app2.delete()

    def test_suggestions_filtered(self):
        response = self.client.get(self.url, data={"q": "Second", "lang": "en-US"})
        parsed = json.loads(response.content)
        eq_(
            parsed,
            [
                {
                    "manifest_url": self.app2.get_manifest_url(),
                    "icon": self.app2.get_icon_url(64),
                    "name": unicode(self.app2.name),
                    "slug": self.app2.app_slug,
                }
            ],
        )
开发者ID:vinu76jsr,项目名称:zamboni,代码行数:38,代码来源:test_api.py


示例20: TestRocketbarApi

class TestRocketbarApi(ESTestCase):
    fixtures = fixture('webapp_337141')

    def setUp(self):
        self.url = reverse('rocketbar-search-api')
        self.refresh('webapp')
        self.client = RestOAuthClient(None)
        self.app1 = Webapp.objects.get(pk=337141)
        self.app1.addondevicetype_set.create(device_type=amo.DEVICE_GAIA.id)
        self.app1.save()

        self.app2 = app_factory(name=u'Something Second Something Something',
                                description=u'Second dèsc' * 25,
                                icon_type='image/png',
                                created=self.days_ago(3),
                                manifest_url='http://rocket.example.com')
        self.app2.addondevicetype_set.create(device_type=amo.DEVICE_GAIA.id)
        self.app2.save()
        self.refresh('webapp')

    def tearDown(self):
        # Cleanup to remove these from the index.
        unindex_webapps([self.app1.id, self.app2.id])
        self.app1.delete()
        self.app2.delete()

    def test_no_results(self):
        with self.assertNumQueries(0):
            response = self.client.get(self.url, data={'q': 'whatever',
                                                       'lang': 'en-US'})
        parsed = json.loads(response.content)
        eq_(parsed, [])

    def test_suggestions(self):
        with self.assertNumQueries(0):
            response = self.client.get(self.url, data={'q': 'Something Second',
                                                       'lang': 'en-US'})
        parsed = json.loads(response.content)
        eq_(len(parsed), 1)
        eq_(parsed[0], {'manifest_url': self.app2.get_manifest_url(),
                        'icon': self.app2.get_icon_url(64),
                        'name': unicode(self.app2.name),
                        'slug': self.app2.app_slug})

    def test_suggestions_multiple_results(self):
        with self.assertNumQueries(0):
            response = self.client.get(self.url, data={'q': 'Something',
                                                       'lang': 'en-US'})
        parsed = json.loads(response.content)
        eq_(len(parsed), 2)
        eq_(parsed[0], {'manifest_url': self.app1.get_manifest_url(),
                        'icon': self.app1.get_icon_url(64),
                        'name': unicode(self.app1.name),
                      'slug': self.app1.app_slug})
        eq_(parsed[1], {'manifest_url': self.app2.get_manifest_url(),
                        'icon': self.app2.get_icon_url(64),
                        'name': unicode(self.app2.name),
                        'slug': self.app2.app_slug})

    def test_suggestion_non_gaia_apps(self):
        AddonDeviceType.objects.all().delete()
        self.app1.save()
        self.app2.save()
        self.refresh('webapp')
        with self.assertNumQueries(0):
            response = self.client.get(self.url, data={'q': 'something'})
        parsed = json.loads(response.content)
        eq_(parsed, [])

    def test_suggestions_limit(self):
        with self.assertNumQueries(0):
            response = self.client.get(self.url, data={'q': 'something',
                                                       'lang': 'en-US',
                                                       'limit': 1})
        parsed = json.loads(response.content)
        eq_(len(parsed), 1)
        eq_(parsed[0], {'manifest_url': self.app1.get_manifest_url(),
                        'icon': self.app1.get_icon_url(64),
                        'name': unicode(self.app1.name),
                        'slug': self.app1.app_slug})
开发者ID:AALEKH,项目名称:zamboni,代码行数:80,代码来源:test_api.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python carriers.get_carrier函数代码示例发布时间:2022-05-27
下一篇:
Python test_oauth.RestOAuth类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap