def setUp(self): super(TestPaymentAccount, self).setUp() AccountCase.setUp(self) self.payment_url = get_absolute_url(get_url('account', pk=self.account.pk), api_name='payments', absolute=False)
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_get_slug(self): Webapp.objects.get(pk=337141).update(app_slug='foo') res = self.client.get(get_absolute_url(('api_dispatch_detail', {'resource_name': 'app', 'app_slug': 'foo'}), api_name='fireplace')) data = json.loads(res.content) eq_(data['id'], '337141')
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})
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))
def test_get_slug(self): Webapp.objects.get(pk=337141).update(app_slug='foo') res = self.client.get( get_absolute_url(('api_dispatch_detail', { 'resource_name': 'app', 'app_slug': 'foo' }), api_name='fireplace')) data = json.loads(res.content) eq_(data['id'], '337141')
def test_put_bogus_payment_account(self): app = self.create_app() data = self.base_data() Price.objects.create(price='1.07') data['price'] = "1.07" data['premium_type'] = 'premium' data['payment_account'] = get_absolute_url(get_url('account', 999), 'payments', False) res = self.client.put(self.get_url, data=json.dumps(data)) eq_(res.status_code, 400) assert not hasattr(app, 'app_payment_account')
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))
def test_put_payment_account_on_free(self, client): client.api.bango.package().get.return_value = {"full": payment_data} self.create_app() data = self.base_data() seller = SolitudeSeller.objects.create(user=self.profile, uuid='uid') acct = PaymentAccount.objects.create( user=self.profile, solitude_seller=seller, agreed_tos=True, seller_uri='uri', uri='uri', bango_package_id=123) data['payment_account'] = get_absolute_url(get_url('account', acct.pk), 'payments', False) res = self.client.put(self.get_url, data=json.dumps(data)) eq_(res.status_code, 400)
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)
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)
def test_get_payment_account(self, client): client.api.bango.package().get.return_value = {"full": payment_data} app = self.create_app() app.premium_type = amo.ADDON_PREMIUM app.save() seller = SolitudeSeller.objects.create(user=self.profile, uuid='uid') acct = PaymentAccount.objects.create( user=self.profile, solitude_seller=seller, agreed_tos=True, seller_uri='uri', uri='uri', bango_package_id=123) AddonPaymentAccount.objects.create( addon=app, payment_account=acct, set_price=1, product_uri="/path/to/app/") p = Price.objects.create(price='1.07') AddonPremium.objects.create(addon=app, price=p) acct_url = get_absolute_url(get_url('account', acct.pk), 'payments', False) res = self.client.get(self.get_url) eq_(res.status_code, 200) data = json.loads(res.content) eq_(data['payment_account'], acct_url) eq_(data['price'], '1.07')
def setUp(self): super(TestLoginHandler, self).setUp() self.list_url = get_absolute_url(list_url('login'), api_name='account')
def test_others(self): url = get_absolute_url(list_url('app'), api_name='fireplace') self._allowed_verbs(self.url, ['get']) self._allowed_verbs(url, [])
def setUp(self): super(TestLoginHandler, self).setUp() self.list_url = get_absolute_url(list_url('login'), api_name='account') self.create_switch('browserid-login')
def setUp(self): super(TestAppDetail, self).setUp() self.url = get_absolute_url(get_url('app', pk=337141), api_name='fireplace')
def url(self, app): return get_absolute_url(get_url('app', pk=app.pk), absolute=False)
def setUp(self): super(TestPaymentAccount, self).setUp() AccountCase.setUp(self) self.payment_url = get_absolute_url( get_url('account', pk=self.account.pk), api_name='payments', absolute=False)