Merge pull request #57 from Gluejar/relaunch_testing

Relaunch testing
pull/1/head
eshellman 2012-10-14 21:27:48 -07:00
commit 8a2da5d67a
3 changed files with 36 additions and 8 deletions

View File

@ -17,7 +17,7 @@
<div><h2>Error: Card authorization for a pledge transaction</h2> <div><h2>Error: Card authorization for a pledge transaction</h2>
<div> <div>
<p>Unglue.it would like to process your pledge, but there's some problem with our credit card processeng. We'd appreciate it if you'd contact <a href="mailto:support@gluejar.com?subject={{ request.get_full_path|urlencode }}">unglue.it support</a>. <p>Unglue.it would like to process your pledge, but there's some problem with our credit card processing. (<b>{{exception.message}}</b>) We'd appreciate it if you'd contact <a href="mailto:support@gluejar.com?subject={{ request.get_full_path|urlencode }}">unglue.it support</a>.
</p> </p>
</div> </div>
</div> </div>

View File

@ -774,7 +774,7 @@ class FundPledgeView(FormView):
if self.transaction.user.id != self.request.user.id: if self.transaction.user.id != self.request.user.id:
# trouble! # trouble!
return render(request, "pledge_user_error.html", {'transaction': self.transaction }) return render(self.request, "pledge_user_error.html", {'transaction': self.transaction })
p = PaymentManager() p = PaymentManager()
@ -786,7 +786,7 @@ class FundPledgeView(FormView):
try: try:
p.make_account(user=self.request.user, host=settings.PAYMENT_PROCESSOR, token=stripe_token) p.make_account(user=self.request.user, host=settings.PAYMENT_PROCESSOR, token=stripe_token)
except baseprocessor.ProcessorError as e: except baseprocessor.ProcessorError as e:
return HttpResponse("There was an error processing your credit card") return render(self.request, "pledge_card_error.html", {'transaction': self.transaction, 'exception':e })
self.transaction.host = settings.PAYMENT_PROCESSOR self.transaction.host = settings.PAYMENT_PROCESSOR
@ -801,7 +801,7 @@ class FundPledgeView(FormView):
if url is not None: if url is not None:
return HttpResponseRedirect(url) return HttpResponseRedirect(url)
else: else:
return render(request, "pledge_card_error.html", {'transaction': self.transaction }) return render(self.request, "pledge_card_error.html", {'transaction': self.transaction })
class NonprofitCampaign(FormView): class NonprofitCampaign(FormView):
template_name="nonprofit.html" template_name="nonprofit.html"

View File

@ -2,6 +2,8 @@ from regluit.core import models
from regluit.payment.models import Transaction, PaymentResponse, Receiver from regluit.payment.models import Transaction, PaymentResponse, Receiver
from regluit.payment.manager import PaymentManager from regluit.payment.manager import PaymentManager
from regluit.payment import stripelib
import django import django
from django.conf import settings from django.conf import settings
@ -222,12 +224,38 @@ def test_relaunch(unglue_it_url = settings.LIVE_SERVER_TEST_URL, do_local=True,
support_button = WebDriverWait(sel,10).until(lambda d: d.find_element_by_css_selector("input[value*='Pledge Now']")) support_button = WebDriverWait(sel,10).until(lambda d: d.find_element_by_css_selector("input[value*='Pledge Now']"))
support_button.click() support_button.click()
# now fill out the credit card ## now fill out the credit card
## CVC should fail but doesn't for now -- hmmm.
sel.execute_script("""document.getElementById("card_Number").value="4242424242424242";""") #
#sel.execute_script("""document.getElementById("card_Number").value={0};""".format(stripelib.ERROR_TESTING['CVC_CHECK_FAIL'][0]))
#sel.execute_script("""document.getElementById("card_ExpiryMonth").value="01";""")
#sel.execute_script("""document.getElementById("card_ExpiryYear").value="14";""")
#sel.execute_script("""document.getElementById("card_CVC").value="123";""")
#
#verify_cc_button = WebDriverWait(sel,10).until(lambda d: d.find_element_by_css_selector("input[value*='Complete Pledge']"))
#verify_cc_button.click()
#
#yield sel
# let's put in a Luhn-invalid # e.g., 4242424242424241
sel.execute_script("""document.getElementById("card_Number").value="4242424242424241";""")
sel.execute_script("""document.getElementById("card_ExpiryMonth").value="01";""") sel.execute_script("""document.getElementById("card_ExpiryMonth").value="01";""")
sel.execute_script("""document.getElementById("card_ExpiryYear").value="14";""") sel.execute_script("""document.getElementById("card_ExpiryYear").value="14";""")
sel.execute_script("""document.getElementById("card_CVC").value="123";""") sel.execute_script("""document.getElementById("card_CVC").value="321";""")
verify_cc_button = WebDriverWait(sel,10).until(lambda d: d.find_element_by_css_selector("input[value*='Complete Pledge']"))
verify_cc_button.click()
# should do a check for "Your card number is incorrect" -- but this doesn't stall -- so we're ok
time.sleep(2)
# should succeed
sel.execute_script("""document.getElementById("card_Number").value={0};""".format(stripelib.TEST_CARDS[0][0]))
sel.execute_script("""document.getElementById("card_ExpiryMonth").value="01";""")
sel.execute_script("""document.getElementById("card_ExpiryYear").value="14";""")
sel.execute_script("""document.getElementById("card_CVC").value="321";""")
time.sleep(2)
verify_cc_button = WebDriverWait(sel,10).until(lambda d: d.find_element_by_css_selector("input[value*='Complete Pledge']")) verify_cc_button = WebDriverWait(sel,10).until(lambda d: d.find_element_by_css_selector("input[value*='Complete Pledge']"))
verify_cc_button.click() verify_cc_button.click()