本文整理汇总了Python中mkt.api.tests.test_oauth.RestOAuthClient类的典型用法代码示例。如果您正苦于以下问题:Python RestOAuthClient类的具体用法?Python RestOAuthClient怎么用?Python RestOAuthClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RestOAuthClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)])
示例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)
示例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)
示例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")
示例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"])
示例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}])
示例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à')
示例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')
示例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'])
示例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'}
示例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)])
示例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')
示例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')
示例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'}