예제 #1
0
    def update_payment_account(self, bundle):
        if 'payment_account' in bundle.data:
            # You cannot specify a payment account and be free.
            # If you specify None, then we will delete the account.
            if (bundle.data['payment_account'] and
                bundle.obj.premium_type == amo.ADDON_FREE):
                raise fields.ApiFieldError(
                    'Free apps cannot have payment accounts.')

            # Delete the old Payment account.
            # See bug 878350.
            try:
                log.info('[1@{0}] Deleting app payment account'
                         .format(bundle.obj.pk))
                AddonPaymentAccount.objects.get(addon=bundle.obj).delete()
            except AddonPaymentAccount.DoesNotExist:
                pass

            # Create a Payment account, only if one is specified.
            if bundle.data['payment_account']:
                acct = self.fields['payment_account'].hydrate(bundle).obj
                log.info('[1@{0}] Creating new app payment account'
                         .format(bundle.obj.pk))
                AddonPaymentAccount.create(
                    provider='bango', addon=bundle.obj,
                    payment_account=acct)
예제 #2
0
 def test_create_new(self, client):
     client.api.bango.product.get_object.side_effect = ObjectDoesNotExist
     client.api.bango.product.post.return_value = {
             'resource_uri': '', 'bango_id': 1}
     AddonPaymentAccount.create(
         'bango', addon=self.app, payment_account=self.account)
     ok_('packageId' in
         client.api.bango.product.post.call_args[1]['data'])
예제 #3
0
파일: test_models.py 프로젝트: at13/zamboni
 def test_create_new(self, client):
     client.api.bango.product.get_object.side_effect = ObjectDoesNotExist
     client.api.bango.product.post.return_value = {
             'resource_uri': '', 'bango_id': 1}
     AddonPaymentAccount.create(
         'bango', addon=self.app, payment_account=self.account)
     ok_('packageId' in
         client.api.bango.product.post.call_args[1]['data'])
예제 #4
0
    def test_create_new(self, client):
        client.get_product.return_value = {
            'objects': [],
            'meta': {'total_count': 0}
        }
        client.get_product_bango.return_value = {
            'objects': [],
            'meta': {'total_count': 0}
        }

        AddonPaymentAccount.create(
            'bango', addon=self.app, payment_account=self.account)
        ok_('public_id' in client.post_product.call_args[1]['data'])
예제 #5
0
    def test_create(self, client):
        client.api.generic.product.get_object.return_value = {
            'resource_uri': 'gpuri'}

        client.api.bango.product.get_object.return_value = {
            'resource_uri': 'bpruri', 'bango_id': 'bango#', 'seller': 'selluri'
        }

        apa = AddonPaymentAccount.create(
            'bango', addon=self.app, payment_account=self.account)
        eq_(apa.addon, self.app)
        eq_(apa.provider, 'bango')
        eq_(apa.account_uri, 'acuri')
        eq_(apa.product_uri, 'bpruri')

        client.api.bango.premium.post.assert_called_with(
            data={'bango': 'bango#', 'price': self.price.price,
                  'currencyIso': 'USD', 'seller_product_bango': 'bpruri'})

        eq_(client.api.bango.rating.post.call_args_list[0][1]['data'],
            {'bango': 'bango#', 'rating': 'UNIVERSAL',
             'ratingScheme': 'GLOBAL', 'seller_product_bango': 'bpruri'})
        eq_(client.api.bango.rating.post.call_args_list[1][1]['data'],
            {'bango': 'bango#', 'rating': 'GENERAL',
             'ratingScheme': 'USA', 'seller_product_bango': 'bpruri'})
예제 #6
0
    def update_payment_account(self, bundle):
        if 'payment_account' in bundle.data:
            if bundle.obj.premium_type == amo.ADDON_FREE:
                raise fields.ApiFieldError(
                    'Free apps cannot have payment accounts.')
            acct = self.fields['payment_account'].hydrate(bundle).obj
            try:
                log.info('[1@%s] Deleting app payment account' % bundle.obj.pk)
                AddonPaymentAccount.objects.get(addon=bundle.obj).delete()
            except AddonPaymentAccount.DoesNotExist:
                pass

            log.info('[1@%s] Creating new app payment account' % bundle.obj.pk)
            AddonPaymentAccount.create(
                provider='bango', addon=bundle.obj,
                payment_account=acct)
예제 #7
0
    def test_create(self, client):
        client.get_product.return_value = {
             'objects': [{'resource_uri': 'gpuri'}],
             'meta': {'total_count': 1}
        }
        client.get_product_bango.return_value = {
            'meta': {'total_count': 1},
            'objects': [{'resource_uri': 'bpruri', 'bango_id': 'bango#',
                         'seller': 'selluri'}]
        }

        apa = AddonPaymentAccount.create(
            'bango', addon=self.app, payment_account=self.account)
        eq_(apa.addon, self.app)
        eq_(apa.provider, 'bango')
        eq_(apa.set_price, self.price.price)
        eq_(apa.account_uri, 'acuri')
        eq_(apa.product_uri, 'bpruri')

        client.post_make_premium.assert_called_with(
            data={'bango': 'bango#', 'price': float(self.price.price),
                  'currencyIso': 'USD', 'seller_product_bango': 'bpruri'})
        client.post_update_rating.assert_called_with(
            data={'bango': 'bango#', 'rating': 'UNIVERSAL',
                  'ratingScheme': 'GLOBAL', 'seller_product_bango': 'bpruri'})
예제 #8
0
파일: test_models.py 프로젝트: at13/zamboni
    def test_create(self, client):
        client.api.generic.product.get_object.return_value = {
            'resource_uri': 'gpuri'}

        client.api.bango.product.get_object.return_value = {
            'resource_uri': 'bpruri', 'bango_id': 'bango#', 'seller': 'selluri'
        }

        apa = AddonPaymentAccount.create(
            'bango', addon=self.app, payment_account=self.account)
        eq_(apa.addon, self.app)
        eq_(apa.provider, 'bango')
        eq_(apa.account_uri, 'acuri')
        eq_(apa.product_uri, 'bpruri')

        client.api.bango.premium.post.assert_called_with(
            data={'bango': 'bango#', 'price': float(self.price.price),
                  'currencyIso': 'USD', 'seller_product_bango': 'bpruri'})

        eq_(client.api.bango.rating.post.call_args_list[0][1]['data'],
            {'bango': 'bango#', 'rating': 'UNIVERSAL',
             'ratingScheme': 'GLOBAL', 'seller_product_bango': 'bpruri'})
        eq_(client.api.bango.rating.post.call_args_list[1][1]['data'],
            {'bango': 'bango#', 'rating': 'GENERAL',
             'ratingScheme': 'USA', 'seller_product_bango': 'bpruri'})
예제 #9
0
    def test_create(self, client):
        client.upsert = (
            fudge.Fake()
                .expects_call()
                .with_args(method='product',
                           params={'seller': 'selluri', 'secret': 'poop',
                                   'external_id': self.app.pk},
                           lookup_by=['external_id'])
                .returns({'resource_uri': 'gpuri'})
                .next_call()
                .with_args(method='product_bango',
                           params={'seller_bango': 'acuri',
                                   'seller_product': 'gpuri',
                                   'name': self.app.name, 'categoryId': 1,
                                   'secret': 'poop'},
                           lookup_by=['seller_product'])
                .returns({'resource_uri': 'bpruri', 'bango_id': 'bango#',
                          'seller': 'selluri'}))

        apa = AddonPaymentAccount.create(
            'bango', addon=self.app, payment_account=self.account)
        eq_(apa.addon, self.app)
        eq_(apa.provider, 'bango')
        eq_(apa.set_price, self.price.price)
        eq_(apa.account_uri, 'acuri')
        eq_(apa.product_uri, 'bpruri')

        client.post_make_premium.assert_called_with(
            data={'bango': 'bango#', 'price': float(self.price.price),
                  'currencyIso': 'USD', 'seller_product_bango': 'bpruri'})
        client.post_update_rating.assert_called_with(
            data={'bango': 'bango#', 'rating': 'UNIVERSAL',
                  'ratingScheme': 'GLOBAL', 'seller_product_bango': 'bpruri'})
예제 #10
0
    def test_create(self, client):
        client.api.generic.product.get_object.return_value = {
            'resource_uri': 'gpuri'}

        client.api.bango.product.get_object.return_value = {
            'resource_uri': 'bpruri', 'bango_id': 'bango#', 'seller': 'selluri'
        }

        apa = AddonPaymentAccount.create(
            'bango', addon=self.app, payment_account=self.account)
        eq_(apa.addon, self.app)
        eq_(apa.provider, 'bango')
        eq_(apa.account_uri, 'acuri')
        eq_(apa.product_uri, 'bpruri')
예제 #11
0
    def test_create_with_free_in_app(self, client):
        client.api.generic.product.get_object.return_value = {
            'resource_uri': 'gpuri'}

        client.api.bango.product.get_object.return_value = {
            'resource_uri': 'bpruri', 'bango_id': 'bango#', 'seller': 'selluri'
        }

        self.app.update(premium_type=amo.ADDON_FREE_INAPP)
        apa = AddonPaymentAccount.create(
            'bango', addon=self.app, payment_account=self.account)
        eq_(apa.addon, self.app)
        eq_(apa.provider, 'bango')
        eq_(apa.account_uri, 'acuri')
        eq_(apa.product_uri, 'bpruri')

        assert not client.api.bango.premium.post.called
예제 #12
0
파일: test_models.py 프로젝트: at13/zamboni
    def test_create_with_free_in_app(self, client):
        client.api.generic.product.get_object.return_value = {
            'resource_uri': 'gpuri'}

        client.api.bango.product.get_object.return_value = {
            'resource_uri': 'bpruri', 'bango_id': 'bango#', 'seller': 'selluri'
        }

        self.app.update(premium_type=amo.ADDON_FREE_INAPP)
        apa = AddonPaymentAccount.create(
            'bango', addon=self.app, payment_account=self.account)
        eq_(apa.addon, self.app)
        eq_(apa.provider, 'bango')
        eq_(apa.account_uri, 'acuri')
        eq_(apa.product_uri, 'bpruri')

        assert not client.api.bango.premium.post.called
예제 #13
0
    def test_create(self, client):
        client.api.generic.product.get_object.return_value = {
            'resource_uri': 'gpuri'
        }

        client.api.bango.product.get_object.return_value = {
            'resource_uri': 'bpruri',
            'bango_id': 'bango#',
            'seller': 'selluri'
        }

        apa = AddonPaymentAccount.create('bango',
                                         addon=self.app,
                                         payment_account=self.account)
        eq_(apa.addon, self.app)
        eq_(apa.provider, 'bango')
        eq_(apa.account_uri, 'acuri')
        eq_(apa.product_uri, 'bpruri')