Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Merge pull request #866 from muffinresearch/fix-exception-for-free-in…
Browse files Browse the repository at this point in the history
…app-889529

Don't make a premium bango product for free in-app (bug 889529)
  • Loading branch information
muffinresearch committed Jul 2, 2013
2 parents 5e5cc75 + 8e28289 commit f035f52
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mkt/developers/models.py
Expand Up @@ -215,8 +215,9 @@ def _create_bango(cls, product_uri, addon, payment_account, secret):
bango_number = res['bango_id']

# If the app is already premium this does nothing.
cls._push_bango_premium(
bango_number, product_uri, float(addon.addonpremium.price.price))
if addon.premium_type != amo.ADDON_FREE_INAPP:
cls._push_bango_premium(bango_number, product_uri,
float(addon.addonpremium.price.price))

return product_uri

Expand Down
21 changes: 21 additions & 0 deletions mkt/developers/tests/test_models.py
Expand Up @@ -220,6 +220,27 @@ def test_create(self, client):
{'bango': 'bango#', 'rating': 'GENERAL',
'ratingScheme': 'USA', 'seller_product_bango': 'bpruri'})

@patch('uuid.uuid4', Mock(return_value='lol'))
@patch('mkt.developers.models.generate_key', Mock(return_value='poop'))
@patch('mkt.developers.models.client')
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

@patch('mkt.developers.models.client')
def test_create_new(self, client):
client.api.bango.product.get_object.side_effect = ObjectDoesNotExist
Expand Down

0 comments on commit f035f52

Please sign in to comment.