コード例 #1
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_store_notification_stores_notification(self):
     # notifications are really stored
     receiver = PayPalIPNReceiver()
     receiver.store_notification("sample-string", uuid="my-uuid")
     assert "my-uuid" in receiver
     stored = receiver["my-uuid"]
     assert IInstantPaymentNotification.providedBy(stored)
コード例 #2
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_validate_no_notification_url(self):
     # we require a notification URL for validation requests
     receiver = PayPalIPNReceiver()
     receiver.validation_url = None
     assert receiver.validate('foo') is None
     receiver.validation_url = ''
     assert receiver.validate('bar') is None
コード例 #3
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_validate_no_action_wo_validation_url(self):
     #  a receiver does not perform any action w/o a validation_url set.
     receiver = PayPalIPNReceiver()
     receiver.validation_url = ''
     assert receiver.validate('x=1') is None
     receiver.validation_url = None
     assert receiver.validate('x=1') is None
コード例 #4
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_store_notification_stores_notification(self):
     # notifications are really stored
     receiver = PayPalIPNReceiver()
     receiver.store_notification("sample-string", uuid="my-uuid")
     assert "my-uuid" in receiver
     stored = receiver["my-uuid"]
     assert IInstantPaymentNotification.providedBy(stored)
コード例 #5
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_index_returns_200_Ok(self):
     # if we deliver normal data we will get a 200 Ok.
     receiver = PayPalIPNReceiver()
     receiver.validation_url = ''
     self.layer.getRootFolder()['app'] = receiver
     browser = Browser()
     browser.open('http://localhost/app/@@index')
     assert browser.headers.get("status") == "200 Ok"
コード例 #6
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_index_returns_empty_body(self):
     # if we deliver normal data we will return with an empty doc.
     receiver = PayPalIPNReceiver()
     receiver.validation_url = ''
     self.layer.getRootFolder()['app'] = receiver
     browser = Browser()
     browser.open('http://localhost/app/@@index')
     assert browser.contents == ''
コード例 #7
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_index_returns_empty_body(self):
     # if we deliver normal data we will return with an empty doc.
     receiver = PayPalIPNReceiver()
     receiver.validation_url = ''
     self.layer.getRootFolder()['app'] = receiver
     browser = Browser()
     browser.open('http://localhost/app/@@index')
     assert browser.contents == ''
コード例 #8
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_index_returns_200_Ok(self):
     # if we deliver normal data we will get a 200 Ok.
     receiver = PayPalIPNReceiver()
     receiver.validation_url = ''
     self.layer.getRootFolder()['app'] = receiver
     browser = Browser()
     browser.open('http://localhost/app/@@index')
     assert browser.headers.get("status") == "200 Ok"
コード例 #9
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_validate(self):
     # we can validate instant payment messages
     receiver = PayPalIPNReceiver()
     result = None
     with http_server(paypal_mode='valid') as server:
         receiver.validation_url = server.url
         result = receiver.validate('some-fake-data')
         sent_body = server.last_request_body
     assert result == "VERIFIED"
     assert sent_body == 'cmd=_notify-validate&some-fake-data'
コード例 #10
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_validate_invlid(self):
     # we get it if a payment notification is invalid
     receiver = PayPalIPNReceiver()
     result = None
     with http_server(paypal_mode='invalid') as server:
         receiver.validation_url = server.url
         result = receiver.validate('some-fake-data')
         sent_body = server.last_request_body
     assert result == "INVALID"
     assert sent_body == 'cmd=_notify-validate&some-fake-data'
コード例 #11
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_validate_invlid(self):
     # we get it if a payment notification is invalid
     receiver = PayPalIPNReceiver()
     result = None
     with http_server(paypal_mode='invalid') as server:
         receiver.validation_url = server.url
         result = receiver.validate('some-fake-data')
         sent_body = server.last_request_body
     assert result == "INVALID"
     assert sent_body == 'cmd=_notify-validate&some-fake-data'
コード例 #12
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_validate(self):
     # we can validate instant payment messages
     receiver = PayPalIPNReceiver()
     result = None
     with http_server(paypal_mode='valid') as server:
         receiver.validation_url = server.url
         result = receiver.validate('some-fake-data')
         sent_body = server.last_request_body
     assert result == "VERIFIED"
     assert sent_body == 'cmd=_notify-validate&some-fake-data'
コード例 #13
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_notify_view_validation_valid(self):
     # we can get successful validations with notify
     receiver = PayPalIPNReceiver()
     receiver.validation_url = self.layer.server.url
     root = self.layer.getRootFolder()
     root['app'] = receiver
     browser = Browser()
     browser.post('http://localhost/app/@@index', 'x=2')
     sent_body = self.layer.server.last_request_body
     assert browser.headers.get("status") == "200 Ok"
     assert sent_body == 'cmd=_notify-validate&x=2'
     assert len(list(receiver.keys())) == 1
     notification = receiver[receiver.keys()[0]]
     assert notification.final_verdict == u'VERIFIED'
コード例 #14
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_notify_view_validation_valid(self):
     # we can get successful validations with notify
     receiver = PayPalIPNReceiver()
     receiver.validation_url = self.layer.server.url
     root = self.layer.getRootFolder()
     root['app'] = receiver
     browser = Browser()
     browser.post('http://localhost/app/@@index', 'x=2')
     sent_body = self.layer.server.last_request_body
     assert browser.headers.get("status") == "200 Ok"
     assert sent_body == 'cmd=_notify-validate&x=2'
     assert len(list(receiver.keys())) == 1
     notification = receiver[receiver.keys()[0]]
     assert notification.final_verdict == u'VERIFIED'
コード例 #15
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_validate_no_action_wo_validation_url(self):
     #  a receiver does not perform any action w/o a validation_url set.
     receiver = PayPalIPNReceiver()
     receiver.validation_url = ''
     assert receiver.validate('x=1') is None
     receiver.validation_url = None
     assert receiver.validate('x=1') is None
コード例 #16
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_validate_no_notification_url(self):
     # we require a notification URL for validation requests
     receiver = PayPalIPNReceiver()
     receiver.validation_url = None
     assert receiver.validate('foo') is None
     receiver.validation_url = ''
     assert receiver.validate('bar') is None
コード例 #17
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_validate_no_post_var_string(self):
     # if we got no post-var-string (or it is empty) we do not validate
     receiver = PayPalIPNReceiver()
     assert receiver.validate(None) is None
     assert receiver.validate('') is None
コード例 #18
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_store_notification_returns_passed_in_uuid(self):
     # we get back our own UUID if we pass one in
     receiver = PayPalIPNReceiver()
     uuid = receiver.store_notification("sample-string", uuid="blah")
     assert uuid == u"blah"
コード例 #19
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_store_notification_returns_uuid(self):
     # `store_notification` returns a UUID
     receiver = PayPalIPNReceiver()
     uuid = receiver.store_notification("sample-string")
     assert uuid is not None
コード例 #20
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_store_notification_returns_uuid(self):
     # `store_notification` returns a UUID
     receiver = PayPalIPNReceiver()
     uuid = receiver.store_notification("sample-string")
     assert uuid is not None
コード例 #21
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_store_notification_returns_passed_in_uuid(self):
     # we get back our own UUID if we pass one in
     receiver = PayPalIPNReceiver()
     uuid = receiver.store_notification("sample-string", uuid="blah")
     assert uuid == u"blah"
コード例 #22
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_validate_no_post_var_string(self):
     # if we got no post-var-string (or it is empty) we do not validate
     receiver = PayPalIPNReceiver()
     assert receiver.validate(None) is None
     assert receiver.validate('') is None
コード例 #23
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_iface(self):
     # the ipn receiver fullfills interface contracts
     receiver = PayPalIPNReceiver()
     verifyClass(IPayPalIPNReceiver, PayPalIPNReceiver)
     verifyObject(IPayPalIPNReceiver, receiver)
コード例 #24
0
ファイル: test_receiver.py プロジェクト: ulif/megrok.paypal
 def test_has_index_view(self):
     # we have an 'index' view for PayPalIPNReceivers
     receiver = PayPalIPNReceiver()
     request = TestRequest()
     view = getMultiAdapter((receiver, request), name='index')
     assert view is not None