Created
November 23, 2011 23:12
-
-
Save andymckay/1390209 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_contribution_good(self): | |
# Checks that the IPN has been by and its all good. | |
con = self.get_contribution() | |
return (con.uuid == None | |
and con.transaction_id == uuid | |
and con.post_data) | |
@patch('paypal.check_purchase') | |
def test_result(self, check_purchase): | |
check_purchase.return_value = 'COMPLETED' | |
response = self.client.get(self.finished) | |
eq_(response.status_code, 200) | |
assert self.addon.has_purchased(self.user) | |
assert not self.is_contribution_good() | |
@patch('paypal.views.urllib2.urlopen') | |
@patch('paypal.check_purchase') | |
def test_result_then_ipn(self, urlopen, check_purchase): | |
urlopen.return_value = self.urlopener('VERIFIED') | |
check_purchase.return_value = 'COMPLETED' | |
response = self.client.get(self.finished) | |
eq_(response.status_code, 200) | |
assert self.addon.has_purchased(self.user) | |
response = self.client.post(self.ipn, sample_ipn) | |
eq_(response.status_code, 200) | |
assert self.addon.has_purchased(self.user) | |
assert self.is_contribution_good() | |
@patch('paypal.views.urllib2.urlopen') | |
def test_ipn_no_result(self, urlopen): | |
urlopen.return_value = self.urlopener('VERIFIED') | |
response = self.client.post(self.ipn, sample_ipn) | |
eq_(response.status_code, 200) | |
assert self.addon.has_purchased(self.user) | |
assert self.is_contribution_good() | |
@patch('paypal.views.urllib2.urlopen') | |
def test_ipn_then_result(self, urlopen): | |
urlopen.return_value = self.urlopener('VERIFIED') | |
response = self.client.post(self.ipn, sample_ipn) | |
eq_(response.status_code, 200) | |
assert not self.addon.has_purchased(self.user) | |
response = self.client.get(self.finished) | |
eq_(response.status_code, 200) | |
assert self.addon.has_purchased(self.user) | |
assert self.is_contribution_good() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment