Example #1
0
    def test_get_list(self, client):
        client.api.bango.package().get.return_value = {"full": payment_data}

        app2 = app_factory(premium_type=amo.ADDON_FREE_INAPP)
        AddonUser.objects.create(addon=app2, user=self.other)
        setup_payment_account(app2, self.other)

        r = self.client.get(list_url('account'))
        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['objects'], [pkg])
Example #2
0
    def test_get_list(self, client):
        client.api.bango.package().get.return_value = {"full": payment_data}

        app2 = app_factory(premium_type=amo.ADDON_FREE_INAPP)
        AddonUser.objects.create(addon=app2, user=self.other)
        setup_payment_account(app2, self.other)

        r = self.client.get(list_url('account'))
        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['objects'], [pkg])
Example #3
0
 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)
Example #4
0
 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)
Example #5
0
    def test_bank_not_required(self):
        """When an account is specified, don't require bank details."""
        payment = setup_payment_account(self.app, self.user).payment_account
        form = forms_payments.BangoPaymentAccountForm(self.data, account=payment)
        assert form.is_valid(), form.errors

        del self.data["bankName"]
        form = forms_payments.BangoPaymentAccountForm(self.data, account=payment)
        assert form.is_valid(), form.errors  # Still valid, even now.
Example #6
0
 def setUp(self):
     BaseOAuth.setUp(self, api_name='payments')
     self.app = Addon.objects.get(pk=337141)
     self.app.update(premium_type=amo.ADDON_FREE_INAPP)
     self.other = UserProfile.objects.get(pk=999)
     AddonUser.objects.create(addon=self.app, user=self.profile)
     self.account = setup_payment_account(self.app, self.profile,
                                          uid='uid2').payment_account
     self.account.name = 'account'
     self.account.save()
Example #7
0
 def setUp(self):
     BaseOAuth.setUp(self, api_name='payments')
     self.app = Addon.objects.get(pk=337141)
     self.app.update(premium_type=amo.ADDON_FREE_INAPP)
     self.other = UserProfile.objects.get(pk=999)
     AddonUser.objects.create(addon=self.app, user=self.profile)
     self.account = setup_payment_account(self.app, self.profile,
                                          uid='uid2').payment_account
     self.account.name = 'account'
     self.account.save()
Example #8
0
    def test_bank_not_required(self):
        """When an account is specified, don't require bank details."""
        payment = setup_payment_account(self.app, self.user).payment_account
        form = forms_payments.BangoPaymentAccountForm(
            self.data, account=payment)
        assert form.is_valid(), form.errors

        del self.data['bankName']
        form = forms_payments.BangoPaymentAccountForm(
            self.data, account=payment)
        assert form.is_valid(), form.errors  # Still valid, even now.
Example #9
0
    def test_on_save(self):
        """Save should just trigger the account's update function."""
        payment = setup_payment_account(self.app, self.user).payment_account
        form = forms_payments.BangoPaymentAccountForm(self.data, account=payment)
        assert form.is_valid(), form.errors

        form.cleaned_data = {"account_name": "foo", "name": "bob"}
        form.save()

        payment = payment.reload()
        eq_(payment.name, "foo")
        self.bango_patcher.api.by_url.assert_called_with("uid")
Example #10
0
 def setUp(self):
     super(TestBangoRedirect, self).setUp()
     self.user = UserProfile.objects.get(username='******')  # steamcube
     self.steamcube = Webapp.objects.get(pk=337141)
     self.otherapp = app_factory(app_slug='otherapp')
     self.reg_user = UserProfile.objects.get(email='*****@*****.**')
     self.summary_url = reverse('lookup.user_summary', args=[self.user.pk])
     self.login(UserProfile.objects.get(username='******'))
     self.steamcube.update(premium_type=amo.ADDON_PREMIUM)
     self.account = setup_payment_account(self.steamcube, self.user)
     self.portal_url = reverse('lookup.bango_portal_from_package',
         args=[self.account.payment_account.account_id])
     self.authentication_token = u'D0A44686-D4A3-4B2F-9BEB-5E4975E35192'
Example #11
0
 def setUp(self):
     super(TestBangoRedirect, self).setUp()
     self.user = UserProfile.objects.get(username='******')  # steamcube
     self.steamcube = Webapp.objects.get(pk=337141)
     self.otherapp = app_factory(app_slug='otherapp')
     self.reg_user = UserProfile.objects.get(email='*****@*****.**')
     self.summary_url = reverse('lookup.user_summary', args=[self.user.pk])
     self.login(UserProfile.objects.get(username='******'))
     self.steamcube.update(premium_type=amo.ADDON_PREMIUM)
     self.account = setup_payment_account(self.steamcube, self.user)
     self.portal_url = reverse('lookup.bango_portal_from_package',
         args=[self.account.payment_account.account_id])
     self.authentication_token = u'D0A44686-D4A3-4B2F-9BEB-5E4975E35192'
Example #12
0
    def test_on_save(self):
        """Save should just trigger the account's update function."""
        payment = setup_payment_account(self.app, self.user).payment_account
        form = forms_payments.BangoPaymentAccountForm(
            self.data, account=payment)
        assert form.is_valid(), form.errors

        form.cleaned_data = {'account_name': 'foo', 'name': 'bob'}
        form.save()

        payment = payment.reload()
        eq_(payment.name, 'foo')
        self.bango_patcher.api.by_url.assert_called_with('uid')