本文整理汇总了Python中mkt.api.base.get_url函数的典型用法代码示例。如果您正苦于以下问题:Python get_url函数的具体用法?Python get_url怎么用?Python get_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_put_no_upsold_for_free
def test_put_no_upsold_for_free(self):
free_webapp = tempfile.NamedTemporaryFile('w', suffix='.webapp').name
self.manifest_copy_over(free_webapp, 'mozball-nice-slug.webapp')
free_app = self.create_app(free_webapp)
free_data = self.base_data()
free_data['name'] = 'mozball free'
self.client.put(get_url('app', free_app.pk), data=json.dumps(free_data))
app = self.create_app()
data = self.base_data()
data['upsold'] = get_absolute_url(get_url('app', free_app.pk),
absolute=False)
res = self.client.put(self.get_url, data=json.dumps(data))
eq_(res.status_code, 400)
示例2: test_get_timestamps
def test_get_timestamps(self):
fmt = '%Y-%m-%dT%H:%M:%S'
rev = Review.objects.create(addon=self.app, user=self.user, body='yes')
res = self.client.get(get_url('rating', rev.pk))
data = json.loads(res.content)
self.assertCloseToNow(datetime.strptime(data['modified'], fmt))
self.assertCloseToNow(datetime.strptime(data['created'], fmt))
示例3: test_install
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)])
示例4: setUp
def setUp(self):
self.app = app_factory()
self.app_url = get_url('app', self.app.pk)
self.version = self.app.current_version
self.file = self.version.all_files[0]
self.request = RequestFactory()
super(TestVersionStatusViewSet, self).setUp()
示例5: test_only_put_by_owner
def test_only_put_by_owner(self, client):
app2 = app_factory(premium_type=amo.ADDON_FREE_INAPP)
AddonUser.objects.create(addon=app2, user=self.other)
acct = setup_payment_account(app2, self.other).payment_account
r = self.client.put(get_url('account', acct.pk),
data=json.dumps(package_data))
eq_(r.status_code, 404)
示例6: test_delete_users_admin
def test_delete_users_admin(self):
user2 = UserProfile.objects.get(pk=31337)
r = Review.objects.create(addon=self.app, user=user2, body='yes')
self.grant_permission(self.user, 'Users:Edit')
res = self.client.delete(get_url('rating', r.pk))
eq_(res.status_code, 204)
eq_(Review.objects.count(), 0)
示例7: test_delete
def test_delete(self, client):
rdel = self.client.delete(get_url('account', self.account.pk))
eq_(rdel.status_code, 204)
client.api.bango.package().get.return_value = {"full": payment_data}
rget = self.client.get(list_url('account'))
eq_(json.loads(rget.content)['objects'], [])
示例8: test_get_upsold
def test_get_upsold(self):
free = Webapp.objects.create(status=amo.STATUS_PUBLIC)
AddonUpsell.objects.create(premium_id=337141, free=free)
res = self.client.get(self.get_url)
eq_(res.json['upsold'],
self.client.get_absolute_url(get_url('app', pk=free.pk),
absolute=False))
示例9: test_delete_app_mine
def test_delete_app_mine(self):
AddonUser.objects.filter(addon=self.app).update(user=self.user)
user2 = UserProfile.objects.get(pk=31337)
r = Review.objects.create(addon=self.app, user=user2, body='yes')
res = self.client.delete(get_url('rating', r.pk))
eq_(res.status_code, 204)
eq_(Review.objects.count(), 0)
示例10: test_put_upsold
def test_put_upsold(self):
free_webapp = tempfile.NamedTemporaryFile('w', suffix='.webapp').name
self.manifest_copy_over(free_webapp, 'mozball-nice-slug.webapp')
free_app = self.create_app(free_webapp)
free_data = self.base_data()
free_data['name'] = 'mozball free'
self.client.put(get_url('app', free_app.pk), data=json.dumps(free_data))
app = self.create_app()
data = self.base_data()
Price.objects.create(price='3.14')
data['premium_type'] = 'premium'
data['price'] = '3.14'
data['upsold'] = get_absolute_url(get_url('app', free_app.pk),
absolute=False)
res = self.client.put(self.get_url, data=json.dumps(data))
eq_(res.status_code, 202)
eq_(app.upsold.free, free_app)
示例11: other
def other(self, shared=False):
other_account = PaymentAccount.objects.create(user_id=31337,
solitude_seller=self.seller, bango_package_id=123,
seller_uri='seller_uri', uri='uri', shared=shared)
other_url = get_absolute_url(
get_url('account', pk=other_account.pk),
api_name='payments', absolute=False)
return self.data(overrides={'payment_account': other_url})
示例12: test_lang
def test_lang(self):
app = app_factory(description={'fr': 'Le blah', 'en-US': 'Blah'})
url = get_url('app', app.pk)
res = self.client.get(url, HTTP_ACCEPT_LANGUAGE='en-US')
eq_(json.loads(res.content)['description'], 'Blah')
res = self.client.get(url, HTTP_ACCEPT_LANGUAGE='fr')
eq_(json.loads(res.content)['description'], 'Le blah')
示例13: test_get
def test_get(self, client):
client.api.bango.package().get.return_value = {"full": payment_data}
r = self.client.get(get_url('account', self.account.pk))
eq_(r.status_code, 200)
data = json.loads(r.content)
pkg = package_data.copy()
pkg['resource_uri'] = '/api/v1/payments/account/%s/' % self.account.pk
eq_(data, pkg)
示例14: test_put
def test_put(self, client):
addr = '[email protected]'
newpkg = package_data.copy()
newpkg['adminEmailAddress'] = addr
r = self.client.put(get_url('account', self.account.pk),
data=json.dumps(newpkg))
eq_(r.status_code, 204)
d = client.api.by_url().patch.call_args[1]['data']
eq_(d['adminEmailAddress'], addr)
示例15: setUp
def setUp(self):
super(TestPrices, self).setUp(api_name='webpay')
self.price = Price.objects.create(name='1', price=Decimal(1))
self.currency = self.make_currency(3, self.price, 'CAD')
self.list_url = list_url('prices')
self.get_url = get_url('prices', self.price.pk)
# If regions change, this will blow up.
assert regions.BR.default_currency == 'BRL'