Пример #1
0
 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)
Пример #2
0
 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)])
Пример #3
0
 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')
Пример #4
0
 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})
Пример #5
0
    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))
Пример #6
0
 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')
Пример #7
0
 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')
Пример #8
0
    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))
Пример #9
0
 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)
Пример #10
0
 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)
Пример #11
0
 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)
Пример #12
0
 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')
Пример #13
0
 def setUp(self):
     super(TestLoginHandler, self).setUp()
     self.list_url = get_absolute_url(list_url('login'), api_name='account')
Пример #14
0
 def setUp(self):
     super(TestLoginHandler, self).setUp()
     self.list_url = get_absolute_url(list_url('login'), api_name='account')
Пример #15
0
 def test_others(self):
     url = get_absolute_url(list_url('app'), api_name='fireplace')
     self._allowed_verbs(self.url, ['get'])
     self._allowed_verbs(url, [])
Пример #16
0
 def setUp(self):
     super(TestLoginHandler, self).setUp()
     self.list_url = get_absolute_url(list_url('login'), api_name='account')
     self.create_switch('browserid-login')
Пример #17
0
 def setUp(self):
     super(TestAppDetail, self).setUp()
     self.url = get_absolute_url(get_url('app', pk=337141),
                                 api_name='fireplace')
Пример #18
0
 def url(self, app):
     return get_absolute_url(get_url('app', pk=app.pk), absolute=False)
Пример #19
0
 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)
Пример #20
0
 def test_others(self):
     url = get_absolute_url(list_url('app'), api_name='fireplace')
     self._allowed_verbs(self.url, ['get'])
     self._allowed_verbs(url, [])
Пример #21
0
 def setUp(self):
     super(TestLoginHandler, self).setUp()
     self.list_url = get_absolute_url(list_url('login'), api_name='account')
     self.create_switch('browserid-login')
Пример #22
0
 def setUp(self):
     super(TestAppDetail, self).setUp()
     self.url = get_absolute_url(get_url('app', pk=337141),
                                 api_name='fireplace')
Пример #23
0
 def url(self, app):
     return get_absolute_url(get_url('app', pk=app.pk), absolute=False)