Permalink
Browse files

add StatusReportFactory

  • Loading branch information...
1 parent aebe121 commit d17a1626c1a3c0e60a3b6e1013b8887970ec22be @Akuryou Akuryou committed Dec 5, 2012
Showing with 30 additions and 2 deletions.
  1. +30 −2 skrill/tests/factories.py
View
@@ -1,12 +1,14 @@
from decimal import Decimal
+import hashlib
import random
from django.contrib.auth.models import User
import factory
-from skrill.models import PaymentRequest
-from skrill.settings import ISO4217
+from skrill import get_secret_word_as_md5
+from skrill.models import PaymentRequest, StatusReport
+from skrill.settings import *
class UserFactory(factory.Factory):
@@ -22,3 +24,29 @@ class PaymentRequestFactory(factory.Factory):
amount = Decimal(random.randrange(10000))/100
currency = random.choice(ISO4217)[0]
+
+class StatusReportFactory(factory.Factory):
+ FACTORY_FOR = StatusReport
+
+ pay_to_email = PAY_TO_EMAIL
+ pay_from_email = "someone@example.com"
+ merchant_id = 12345
+ payment_request = PaymentRequestFactory()
+ mb_transaction_id = 12345
+ mb_amount = payment_request.amount
+ mb_currency = payment_request.currency
+ status = 0
+ md5sig = ''
+ amount = payment_request.amount
+ currency = payment_request.currency
+
+ def _generate_md5_signature(self):
+ m = hashlib.md5()
+ m.update(str(self.merchant_id))
+ m.update(str(self.transaction_id))
+ m.update(get_secret_word_as_md5())
+ m.update(str(self.mb_amount))
+ m.update(self.mb_currency)
+ m.update(str(self.status))
+ self.md5sig = m.hexdigest().upper()
+

0 comments on commit d17a162

Please sign in to comment.