Getting rid of tests that call PaymentManager.pledge

pull/1/head
Raymond Yee 2013-06-25 11:05:52 -07:00
parent 0950c3bc40
commit 22dc844b07
3 changed files with 1 additions and 123 deletions

View File

@ -180,72 +180,6 @@ class PledgeTest(TestCase):
valid(url)
except ValidationError, e:
print e
@unittest.expectedFailure
def test_pledge_single_receiver(self):
try:
p = PaymentManager()
# Note, set this to 1-5 different receivers with absolute amounts for each
receiver_list = [{'email':settings.PAYPAL_GLUEJAR_EMAIL, 'amount':20.00}]
t, url = p.pledge('USD', receiver_list, campaign=None, list=None, user=None)
self.validateRedirect(t, url, 1)
loginSandbox(self.selenium)
paySandbox(self, self.selenium, url)
# sleep to make sure the transaction has time to complete
time.sleep(10)
# by now we should have received the IPN
# right now, for running on machine with no acess to IPN, we manually update statuses
p.checkStatus()
t = Transaction.objects.get(id=t.id)
self.assertEqual(t.status, IPN_PAY_STATUS_COMPLETED)
self.assertEqual(t.receiver_set.all()[0].status, IPN_TXN_STATUS_COMPLETED)
except:
traceback.print_exc()
@unittest.expectedFailure
def test_pledge_mutiple_receiver(self):
p = PaymentManager()
# Note, set this to 1-5 different receivers with absolute amounts for each
receiver_list = [{'email':settings.PAYPAL_GLUEJAR_EMAIL, 'amount':20.00},
{'email':settings.PAYPAL_TEST_RH_EMAIL, 'amount':10.00}]
t, url = p.pledge('USD', receiver_list, campaign=None, list=None, user=None)
self.validateRedirect(t, url, 2)
loginSandbox(self.selenium)
paySandbox(self, self.selenium, url)
# by now we should have received the IPN
# right now, for running on machine with no acess to IPN, we manually update statuses
p.checkStatus()
t = Transaction.objects.get(id=t.id)
self.assertEqual(t.status, IPN_PAY_STATUS_COMPLETED)
self.assertEqual(t.receiver_set.all()[0].status, IPN_TXN_STATUS_COMPLETED)
self.assertEqual(t.receiver_set.all()[1].status, IPN_TXN_STATUS_COMPLETED)
@unittest.expectedFailure
def test_pledge_too_much(self):
p = PaymentManager()
# Note, set this to 1-5 different receivers with absolute amounts for each
receiver_list = [{'email':settings.PAYPAL_GLUEJAR_EMAIL, 'amount':50000.00}]
t, url = p.pledge('USD', receiver_list, campaign=None, list=None, user=None)
self.validateRedirect(t, url, 1)
def tearDown(self):
self.selenium.quit()
@ -424,7 +358,7 @@ class AccountTest(TestCase):
def suite():
#testcases = [PledgeTest, AuthorizeTest, TransactionTest]
#testcases = [AuthorizeTest, TransactionTest, CreditTest]
testcases = [TransactionTest, CreditTest]
suites = unittest.TestSuite([unittest.TestLoader().loadTestsFromTestCase(testcase) for testcase in testcases])
return suites

View File

@ -13,7 +13,6 @@ urlpatterns = patterns(
if settings.DEBUG:
urlpatterns += patterns(
"regluit.payment.views",
url(r"^testpledge", "testPledge"),
url(r"^testauthorize", "testAuthorize"),
url(r"^testexecute", "testExecute"),
url(r"^testcancel", "testCancel"),

View File

@ -205,7 +205,6 @@ def testModify(request):
return HttpResponse("Error")
'''
http://BASE/testfinish?transaction=2
@ -225,52 +224,6 @@ def testFinish(request):
return HttpResponse(message)
'''
http://BASE/testpledge?campaign=2
Example that initiates an instant payment for a campaign
'''
def testPledge(request):
p = PaymentManager()
if 'campaign' in request.REQUEST.keys():
campaign_id = request.REQUEST['campaign']
else:
campaign_id = None
# see whether there is a user logged in.
if request.user.is_authenticated():
user = request.user
else:
user = None
# Note, set this to 1-5 different receivers with absolute amounts for each
#receiver_list = [{'email':TEST_RECEIVERS[0], 'amount':20.00},{'email':TEST_RECEIVERS[1], 'amount':10.00}]
if 'pledge_amount' in request.REQUEST.keys():
pledge_amount = request.REQUEST['pledge_amount']
receiver_list = [{'email':TEST_RECEIVERS[0], 'amount':pledge_amount}]
else:
receiver_list = [{'email':TEST_RECEIVERS[0], 'amount':78.90}, {'email':TEST_RECEIVERS[1], 'amount':34.56}]
if campaign_id:
campaign = Campaign.objects.get(id=int(campaign_id))
t, url = p.pledge('USD', TARGET_TYPE_CAMPAIGN, receiver_list, campaign=campaign, list=None, user=user, return_url=None)
else:
t, url = p.pledge('USD', TARGET_TYPE_NONE, receiver_list, campaign=None, list=None, user=user, return_url=None)
if url:
logger.info("testPledge: " + url)
return HttpResponseRedirect(url)
else:
response = t.error
logger.info("testPledge: Error " + str(t.error))
return HttpResponse(response)
def runTests(request):
try:
@ -282,14 +235,6 @@ def runTests(request):
# Run the authorize test
test = AuthorizeTest('test_authorize')
test.run(result)
# Run the pledge test
test = PledgeTest('test_pledge_single_receiver')
test.run(result)
# Run the pledge failure test
test = PledgeTest('test_pledge_too_much')
test.run(result)
output = "Tests Run: " + str(result.testsRun) + str(result.errors) + str(result.failures)
logger.info(output)