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

Commit

Permalink
Merge pull request #221 from davidbgk/833445-removing-issuer-notice
Browse files Browse the repository at this point in the history
 Removing Issuer and Notice models (bug 833445)
  • Loading branch information
davidbgk committed Aug 5, 2013
2 parents 4974641 + af391ff commit 675eded
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 195 deletions.
5 changes: 0 additions & 5 deletions lib/solitude/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from ..utils import SlumberWrapper
from .constants import ACCESS_PURCHASE
from .errors import ERROR_STRINGS
from webpay.pay.models import Issuer


log = logging.getLogger('w.solitude')
Expand Down Expand Up @@ -273,10 +272,6 @@ def get_transaction(self, uuid):
notes = transaction['notes']
if notes:
transaction['notes'] = json.loads(notes)
issuer = transaction['notes'].get('issuer')
if issuer:
# If there's an issuer there, get it.
transaction['notes']['issuer'] = Issuer.objects.get(pk=issuer)
return transaction


Expand Down
9 changes: 0 additions & 9 deletions lib/solitude/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from lib.solitude.api import client, SellerNotConfigured
from lib.solitude.errors import ERROR_STRINGS
from webpay.pay.models import Issuer


class SolitudeAPITest(TestCase):
Expand Down Expand Up @@ -234,11 +233,3 @@ def test_notes_transactions(self, slumber):
}
trans = client.get_transaction('x')
eq_(trans['notes'], {'foo': 'bar'})

def test_notes_issuer_transactions(self, slumber):
iss = Issuer.objects.create()
slumber.generic.transaction.get_object.return_value = {
'notes': json.dumps({'issuer': iss.pk})
}
trans = client.get_transaction('x')
eq_(trans['notes']['issuer'], iss)
1 change: 1 addition & 0 deletions migrations/012-drop-notices.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE `notices`;
1 change: 1 addition & 0 deletions migrations/013-drop-issuers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE `issuers`;
3 changes: 3 additions & 0 deletions webpay/pay/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NOT_SIMULATED = 0
SIMULATED_POSTBACK = 1
SIMULATED_CHARGEBACK = 2
11 changes: 11 additions & 0 deletions webpay/pay/fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.db import models


class BlobField(models.Field):
"""
MySQL blob column.
"""
description = "blob"

def db_type(self, **kw):
return 'blob'
121 changes: 0 additions & 121 deletions webpay/pay/models.py

This file was deleted.

10 changes: 1 addition & 9 deletions webpay/pay/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

from webpay.base.helpers import absolutify
from webpay.constants import TYP_CHARGEBACK, TYP_POSTBACK
from .models import (Notice, NOT_SIMULATED, SIMULATED_POSTBACK,
SIMULATED_CHARGEBACK)
from .constants import NOT_SIMULATED, SIMULATED_POSTBACK, SIMULATED_CHARGEBACK
from .utils import send_pay_notice, trans_id

log = logging.getLogger('w.pay.tasks')
Expand Down Expand Up @@ -361,13 +360,6 @@ def _notify(notifier_task, trans, extra_response=None, simulated=NOT_SIMULATED,
success, last_error = send_pay_notice(url, trans['type'], signed_notice,
trans['uuid'], notifier_task,
task_args, simulated=simulated)
s = Notice._meta.get_field_by_name('last_error')[0].max_length
last_error = last_error[:s] # truncate to fit
Notice.objects.create(transaction_uuid=trans['uuid'],
success=success,
url=url,
simulated=simulated,
last_error=last_error)


def _prepare_notice(trans):
Expand Down
10 changes: 0 additions & 10 deletions webpay/pay/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from lib.solitude import constants

from webpay.base.tests import BasicSessionCase
from webpay.pay.models import Issuer, ISSUER_ACTIVE
from webpay.pay.samples import JWTtester

sample = os.path.join(os.path.dirname(__file__), 'sample.key')
Expand All @@ -19,7 +18,6 @@ def setUp(self):
self.url = reverse('pay.lobby')
self.key = 'public.key'
self.secret = 'private.secret'
self.create()

def get(self, payload):
return self.client.get('%s?req=%s' % (self.url, payload))
Expand All @@ -35,14 +33,6 @@ def request(self, **kw):
kw.setdefault('app_secret', settings.SECRET)
return super(Base, self).request(**kw)

def create(self, key=None, secret=None):
key = key or self.key
secret = secret or self.secret
self.iss = Issuer.objects.create(issuer_key=key,
status=ISSUER_ACTIVE)
with self.settings(INAPP_KEY_PATHS={None: sample}, DEBUG=True):
self.iss.set_private_key(secret)

def set_secret(self, get_active_product):
get_active_product.return_value = {
'secret': self.secret,
Expand Down
3 changes: 0 additions & 3 deletions webpay/pay/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from nose.tools import eq_

from webpay.pay.forms import VerifyForm
from webpay.pay.models import ISSUER_INACTIVE

from . import Base, sample

Expand Down Expand Up @@ -89,8 +88,6 @@ def test_not_public(self):
# an active status in solitude.
raise SkipTest

self.iss.status = ISSUER_INACTIVE
self.iss.save()
payload = self.request(iss=self.key, app_secret=self.secret)
with self.settings(INAPP_KEY_PATHS={None: sample}, DEBUG=True):
form = VerifyForm({'req': payload})
Expand Down
37 changes: 0 additions & 37 deletions webpay/pay/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from lib.solitude import constants
from webpay.constants import TYP_CHARGEBACK, TYP_POSTBACK
from webpay.pay import tasks
from webpay.pay.models import Notice, SIMULATED_POSTBACK, SIMULATED_CHARGEBACK
from webpay.pay.samples import JWTtester

from .test_views import sample
Expand Down Expand Up @@ -90,10 +89,6 @@ def req_ok(req):
.has_attr(text=self.trans_uuid)
.expects('raise_for_status'))
self.notify()
notice = Notice.objects.get()
eq_(notice.transaction_uuid, self.trans_uuid)
eq_(notice.success, True)
eq_(notice.url, url)

@fudge.patch('webpay.pay.utils.requests')
@mock.patch('lib.solitude.api.client.slumber')
Expand All @@ -117,10 +112,6 @@ def req_ok(req):
.has_attr(text=self.trans_uuid)
.expects('raise_for_status'))
self.do_chargeback('refund')
notice = Notice.objects.get()
eq_(notice.transaction_uuid, self.trans_uuid)
eq_(notice.success, True)
eq_(notice.url, url)

@fudge.patch('webpay.pay.utils.requests')
@mock.patch('lib.solitude.api.client.slumber')
Expand All @@ -139,10 +130,6 @@ def req_ok(req):
.has_attr(text=self.trans_uuid)
.expects('raise_for_status'))
self.do_chargeback('reversal')
notice = Notice.objects.get()
eq_(notice.transaction_uuid, self.trans_uuid)
eq_(notice.last_error, '')
eq_(notice.success, True)

@mock.patch('webpay.pay.utils.requests')
@mock.patch('lib.solitude.api.client.slumber')
Expand All @@ -160,10 +147,6 @@ def test_notify_timeout(self, marketplace, solitude, requests):
self.set_secret_mock(solitude, 'f')
requests.post.side_effect = Timeout('Timeout')
self.notify()
notice = Notice.objects.get()
eq_(notice.success, False)
er = notice.last_error
assert 'Timeout' in er, 'Unexpected: %s' % er

@mock.patch('lib.solitude.api.client.slumber')
@mock.patch('webpay.pay.tasks.payment_notify.retry')
Expand All @@ -182,10 +165,6 @@ def test_any_error(self, fake_req, marketplace, solitude):
self.set_secret_mock(solitude, 'f')
fake_req.expects('post').raises(RequestException('some http error'))
self.notify()
notice = Notice.objects.get()
eq_(notice.success, False)
er = notice.last_error
assert 'some http error' in er, 'Unexpected: %s' % er

@fudge.patch('webpay.pay.utils.requests')
@mock.patch('lib.solitude.api.client.slumber')
Expand All @@ -198,10 +177,6 @@ def test_bad_status(self, fake_req, marketplace, solitude):
.raises(urllib2.HTTPError('url', 500, 'Error',
[], None)))
self.notify()
notice = Notice.objects.get()
eq_(notice.success, False)
er = notice.last_error
assert 'HTTP Error' in er, 'Unexpected: %s' % er

@fudge.patch('webpay.pay.utils.requests')
@mock.patch('lib.solitude.api.client.slumber')
Expand All @@ -211,8 +186,6 @@ def test_invalid_app_response(self, fake_req, slumber):
.provides('raise_for_status')
.has_attr(text='<not a valid response>'))
self.notify()
notice = Notice.objects.get()
eq_(notice.success, False)

@mock.patch('lib.solitude.api.client.slumber')
@mock.patch('webpay.pay.utils.requests')
Expand Down Expand Up @@ -298,11 +271,6 @@ def req_ok(req):
.has_attr(text=self.trans_uuid)
.expects('raise_for_status'))
self.notify(payload)
notice = Notice.objects.get()
assert notice.transaction_uuid, notice
eq_(notice.success, True)
eq_(notice.url, url)
eq_(notice.simulated, SIMULATED_POSTBACK)

@fudge.patch('webpay.pay.utils.requests')
def test_chargeback(self, slumber, fake_req):
Expand All @@ -325,11 +293,6 @@ def req_ok(req):
.has_attr(text=self.trans_uuid)
.expects('raise_for_status'))
self.notify(payload)
notice = Notice.objects.get()
assert notice.transaction_uuid, notice
eq_(notice.success, True)
eq_(notice.url, url)
eq_(notice.simulated, SIMULATED_CHARGEBACK)

@fudge.patch('webpay.pay.utils.requests')
def test_chargeback_reason(self, slumber, fake_req):
Expand Down
2 changes: 1 addition & 1 deletion webpay/pay/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from lib.marketplace.api import client

from .models import NOT_SIMULATED
from .constants import NOT_SIMULATED

log = logging.getLogger('w.pay.utils')

Expand Down

0 comments on commit 675eded

Please sign in to comment.