2011-09-27 12:48:11 +00:00
|
|
|
"""
|
|
|
|
This file demonstrates writing tests using the unittest module. These will pass
|
|
|
|
when you run "manage.py test".
|
|
|
|
|
|
|
|
Replace this with more appropriate tests for your application.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from django.test import TestCase
|
2011-10-07 21:17:54 +00:00
|
|
|
from django.utils import unittest
|
2012-01-04 15:52:19 +00:00
|
|
|
from django.conf import settings
|
2012-05-16 02:47:57 +00:00
|
|
|
from django.contrib.auth.models import User
|
2011-10-04 11:55:39 +00:00
|
|
|
from regluit.payment.manager import PaymentManager
|
|
|
|
from regluit.payment.models import Transaction
|
2011-10-08 03:11:57 +00:00
|
|
|
from regluit.core.models import Campaign, Wishlist, Work
|
2012-05-16 02:47:57 +00:00
|
|
|
from regluit.core.signals import handle_transaction_charged
|
2011-10-04 11:55:39 +00:00
|
|
|
from regluit.payment.parameters import *
|
2012-10-03 12:56:29 +00:00
|
|
|
from regluit.payment.paypal import *
|
2011-10-04 11:55:39 +00:00
|
|
|
import traceback
|
|
|
|
from django.core.validators import URLValidator
|
|
|
|
from django.core.exceptions import ValidationError
|
|
|
|
import time
|
2012-01-26 16:21:49 +00:00
|
|
|
from selenium import webdriver
|
|
|
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
|
|
import logging
|
2012-01-26 17:44:00 +00:00
|
|
|
import os
|
2011-10-08 03:11:57 +00:00
|
|
|
from decimal import Decimal as D
|
2012-03-07 19:42:16 +00:00
|
|
|
from regluit.utils.localdatetime import now
|
2012-03-12 22:55:14 +00:00
|
|
|
from datetime import timedelta
|
2011-10-08 03:11:57 +00:00
|
|
|
|
2012-01-26 17:44:00 +00:00
|
|
|
def setup_selenium():
|
|
|
|
# Set the display window for our xvfb
|
|
|
|
os.environ['DISPLAY'] = ':99'
|
|
|
|
|
2012-01-26 16:21:49 +00:00
|
|
|
def set_test_logging():
|
|
|
|
|
|
|
|
# Setup debug logging to our console so we can watch
|
|
|
|
defaultLogger = logging.getLogger('')
|
|
|
|
defaultLogger.addHandler(logging.StreamHandler())
|
|
|
|
defaultLogger.setLevel(logging.DEBUG)
|
|
|
|
|
|
|
|
# Set the selenium logger to info
|
|
|
|
sel = logging.getLogger("selenium")
|
|
|
|
sel.setLevel(logging.INFO)
|
|
|
|
|
2012-03-14 22:06:29 +00:00
|
|
|
def loginSandbox(selenium):
|
2011-10-04 11:55:39 +00:00
|
|
|
|
|
|
|
print "LOGIN SANDBOX"
|
|
|
|
|
|
|
|
try:
|
2012-01-26 16:21:49 +00:00
|
|
|
selenium.get('https://developer.paypal.com/')
|
|
|
|
login_email = WebDriverWait(selenium, 10).until(lambda d : d.find_element_by_id("login_email"))
|
|
|
|
login_email.click()
|
|
|
|
login_email.send_keys(settings.PAYPAL_SANDBOX_LOGIN)
|
|
|
|
|
|
|
|
login_password = WebDriverWait(selenium, 10).until(lambda d : d.find_element_by_id("login_password"))
|
|
|
|
login_password.click()
|
|
|
|
login_password.send_keys(settings.PAYPAL_SANDBOX_PASSWORD)
|
|
|
|
|
|
|
|
submit_button = WebDriverWait(selenium, 10).until(lambda d : d.find_element_by_css_selector("input[class=\"formBtnOrange\"]"))
|
|
|
|
submit_button.click()
|
|
|
|
|
2011-10-04 11:55:39 +00:00
|
|
|
except:
|
|
|
|
traceback.print_exc()
|
|
|
|
|
2012-03-19 18:46:41 +00:00
|
|
|
def paySandbox(test, selenium, url, authorize=False, already_at_url=False, sleep_time=20):
|
|
|
|
|
2011-10-04 11:55:39 +00:00
|
|
|
|
2012-01-26 16:21:49 +00:00
|
|
|
if authorize:
|
|
|
|
print "AUTHORIZE SANDBOX"
|
|
|
|
else:
|
|
|
|
print "PAY SANDBOX"
|
2011-10-04 11:55:39 +00:00
|
|
|
|
|
|
|
try:
|
2012-01-26 19:50:14 +00:00
|
|
|
# We need this sleep to make sure the JS engine is finished from the sandbox loging page
|
2012-03-19 18:46:41 +00:00
|
|
|
time.sleep(sleep_time)
|
2012-01-26 19:50:14 +00:00
|
|
|
|
2012-03-19 18:46:41 +00:00
|
|
|
if not already_at_url:
|
|
|
|
selenium.get(url)
|
|
|
|
print "Opened URL %s" % url
|
2012-01-26 19:50:14 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
# Button is only visible if the login box is NOT open
|
|
|
|
# If the login box is open, the email/pw fiels are already accessible
|
2012-03-21 21:53:33 +00:00
|
|
|
login_element = WebDriverWait(selenium, 10).until(lambda d : d.find_element_by_id("loadLogin"))
|
2012-01-26 19:50:14 +00:00
|
|
|
login_element.click()
|
|
|
|
|
|
|
|
# This sleep is needed for js to slide the buyer login into view. The elements are always in the DOM
|
|
|
|
# so selenium can find them, but we need them in view to interact
|
2012-03-19 18:46:41 +00:00
|
|
|
time.sleep(sleep_time)
|
2012-01-26 19:50:14 +00:00
|
|
|
except:
|
|
|
|
print "Ready for Login"
|
|
|
|
|
|
|
|
email_element = WebDriverWait(selenium, 60).until(lambda d : d.find_element_by_id("login_email"))
|
2012-01-26 16:21:49 +00:00
|
|
|
email_element.click()
|
2012-03-20 21:10:21 +00:00
|
|
|
email_element.clear()
|
2012-01-26 16:21:49 +00:00
|
|
|
email_element.send_keys(settings.PAYPAL_BUYER_LOGIN)
|
2012-01-04 15:52:19 +00:00
|
|
|
|
2012-01-26 19:50:14 +00:00
|
|
|
password_element = WebDriverWait(selenium, 60).until(lambda d : d.find_element_by_id("login_password"))
|
2012-01-26 16:21:49 +00:00
|
|
|
password_element.click()
|
2012-03-20 21:10:21 +00:00
|
|
|
password_element.clear()
|
2012-01-26 16:21:49 +00:00
|
|
|
password_element.send_keys(settings.PAYPAL_BUYER_PASSWORD)
|
|
|
|
|
2012-01-26 19:50:14 +00:00
|
|
|
submit_button = WebDriverWait(selenium, 60).until(lambda d : d.find_element_by_id("submitLogin"))
|
2012-01-26 16:21:49 +00:00
|
|
|
submit_button.click()
|
2012-01-26 19:50:14 +00:00
|
|
|
|
|
|
|
# This sleep makes sure js has time to animate out the next page
|
2012-03-19 18:46:41 +00:00
|
|
|
time.sleep(sleep_time)
|
2012-01-26 16:21:49 +00:00
|
|
|
|
2012-01-26 19:50:14 +00:00
|
|
|
final_submit = WebDriverWait(selenium, 60).until(lambda d : d.find_element_by_id("submit.x"))
|
2012-01-26 16:21:49 +00:00
|
|
|
final_submit.click()
|
2012-01-26 19:50:14 +00:00
|
|
|
|
|
|
|
# This makes sure the processing of the final submit is complete
|
2012-03-19 18:46:41 +00:00
|
|
|
time.sleep(sleep_time)
|
2012-01-26 19:50:14 +00:00
|
|
|
|
|
|
|
# Don't wait too long for this, it isn't really needed. By the time JS has gotten around to
|
|
|
|
# displaying this element, the redirect has usually occured
|
|
|
|
try:
|
|
|
|
return_button = WebDriverWait(selenium, 10).until(lambda d : d.find_element_by_id("returnToMerchant"))
|
|
|
|
return_button.click()
|
|
|
|
except:
|
|
|
|
blah = "blah"
|
2011-10-04 11:55:39 +00:00
|
|
|
|
|
|
|
except:
|
|
|
|
traceback.print_exc()
|
|
|
|
|
2012-01-26 19:50:14 +00:00
|
|
|
print "Tranasction Complete"
|
2012-01-26 16:21:49 +00:00
|
|
|
|
2012-04-25 20:10:53 +00:00
|
|
|
def payAmazonSandbox(sel):
|
2012-05-17 01:16:06 +00:00
|
|
|
|
2012-05-18 22:06:35 +00:00
|
|
|
print "Expected title: {0} \n Actual Title: {1}".format('Amazon.com Sign In', sel.title)
|
|
|
|
# does it make sense to throw up if there is problem....what better invariants?
|
2012-04-25 20:10:53 +00:00
|
|
|
login_email = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("input#ap_email"))
|
|
|
|
login_email.click()
|
|
|
|
login_email.clear()
|
|
|
|
login_email.send_keys('supporter1@raymondyee.net')
|
|
|
|
login_password = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("input#ap_password"))
|
|
|
|
login_password.click()
|
|
|
|
login_password.clear()
|
|
|
|
login_password.send_keys('testpw__')
|
|
|
|
submit_button = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("input#signInSubmit"))
|
|
|
|
submit_button.click()
|
|
|
|
time.sleep(2)
|
|
|
|
|
|
|
|
# sel.find_element_by_css_selector("input[type='image']")
|
2012-05-18 22:06:35 +00:00
|
|
|
print "Expected title: {0} \n Actual Title: {1}".format('Amazon Payments', sel.title)
|
2012-04-25 20:10:53 +00:00
|
|
|
print "looking for credit_card_confirm", sel.current_url
|
|
|
|
credit_card_confirm = WebDriverWait(sel,20).until(lambda d: d.find_elements_by_css_selector("input[type='image']"))
|
2012-05-18 22:06:35 +00:00
|
|
|
credit_card_confirm[-1].click()
|
2012-04-25 20:10:53 +00:00
|
|
|
|
2012-05-18 22:06:35 +00:00
|
|
|
#print "looking for payment_confirm", sel.current_url
|
|
|
|
#payment_confirm = WebDriverWait(sel,20).until(lambda d: d.find_elements_by_css_selector("input[type='image']"))
|
|
|
|
#print "payment_confirm ", payment_confirm
|
|
|
|
#print "len(payment_confirm)", len(payment_confirm)
|
|
|
|
#time.sleep(1)
|
|
|
|
#payment_confirm[-1].click()
|
2012-04-25 20:10:53 +00:00
|
|
|
|
2011-10-04 11:55:39 +00:00
|
|
|
class PledgeTest(TestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
self.verificationErrors = []
|
|
|
|
# This is an empty array where we will store any verification errors
|
|
|
|
# we find in our tests
|
|
|
|
|
2012-01-26 17:44:00 +00:00
|
|
|
setup_selenium()
|
2012-01-26 16:21:49 +00:00
|
|
|
self.selenium = webdriver.Firefox()
|
|
|
|
set_test_logging()
|
2011-10-04 11:55:39 +00:00
|
|
|
|
|
|
|
def validateRedirect(self, t, url, count):
|
|
|
|
|
|
|
|
self.assertNotEqual(url, None)
|
|
|
|
self.assertNotEqual(t, None)
|
|
|
|
self.assertEqual(t.receiver_set.all().count(), count)
|
|
|
|
self.assertEqual(t.receiver_set.all()[0].amount, t.amount)
|
|
|
|
self.assertEqual(t.receiver_set.all()[0].currency, t.currency)
|
2012-01-26 16:21:49 +00:00
|
|
|
# self.assertNotEqual(t.ref1Gerence, None)
|
2011-10-04 11:55:39 +00:00
|
|
|
self.assertEqual(t.error, None)
|
2012-01-04 15:52:19 +00:00
|
|
|
self.assertEqual(t.status, IPN_PAY_STATUS_CREATED)
|
2011-10-04 11:55:39 +00:00
|
|
|
|
|
|
|
valid = URLValidator(verify_exists=True)
|
|
|
|
try:
|
|
|
|
valid(url)
|
|
|
|
except ValidationError, e:
|
|
|
|
print e
|
|
|
|
|
2012-01-04 15:52:19 +00:00
|
|
|
@unittest.expectedFailure
|
2011-10-04 11:55:39 +00:00
|
|
|
def test_pledge_single_receiver(self):
|
|
|
|
|
|
|
|
try:
|
|
|
|
p = PaymentManager()
|
|
|
|
|
|
|
|
# Note, set this to 1-5 different receivers with absolute amounts for each
|
2012-01-04 15:52:19 +00:00
|
|
|
receiver_list = [{'email':settings.PAYPAL_GLUEJAR_EMAIL, 'amount':20.00}]
|
2012-08-31 07:16:04 +00:00
|
|
|
t, url = p.pledge('USD', receiver_list, campaign=None, list=None, user=None)
|
2011-10-04 11:55:39 +00:00
|
|
|
|
|
|
|
self.validateRedirect(t, url, 1)
|
|
|
|
|
2012-03-14 22:06:29 +00:00
|
|
|
loginSandbox(self.selenium)
|
2011-10-04 11:55:39 +00:00
|
|
|
paySandbox(self, self.selenium, url)
|
2012-01-26 16:21:49 +00:00
|
|
|
|
|
|
|
# sleep to make sure the transaction has time to complete
|
|
|
|
time.sleep(10)
|
2012-01-04 15:52:19 +00:00
|
|
|
|
2011-10-04 11:55:39 +00:00
|
|
|
# by now we should have received the IPN
|
2012-01-04 15:52:19 +00:00
|
|
|
# right now, for running on machine with no acess to IPN, we manually update statuses
|
|
|
|
p.checkStatus()
|
|
|
|
t = Transaction.objects.get(id=t.id)
|
|
|
|
|
2011-10-04 11:55:39 +00:00
|
|
|
self.assertEqual(t.status, IPN_PAY_STATUS_COMPLETED)
|
|
|
|
self.assertEqual(t.receiver_set.all()[0].status, IPN_TXN_STATUS_COMPLETED)
|
|
|
|
|
|
|
|
except:
|
|
|
|
traceback.print_exc()
|
2012-01-04 15:52:19 +00:00
|
|
|
|
|
|
|
@unittest.expectedFailure
|
2011-10-04 11:55:39 +00:00
|
|
|
def test_pledge_mutiple_receiver(self):
|
|
|
|
|
|
|
|
p = PaymentManager()
|
|
|
|
|
|
|
|
# Note, set this to 1-5 different receivers with absolute amounts for each
|
2012-01-04 15:52:19 +00:00
|
|
|
receiver_list = [{'email':settings.PAYPAL_GLUEJAR_EMAIL, 'amount':20.00},
|
|
|
|
{'email':settings.PAYPAL_TEST_RH_EMAIL, 'amount':10.00}]
|
2011-10-04 11:55:39 +00:00
|
|
|
|
2012-08-31 07:16:04 +00:00
|
|
|
t, url = p.pledge('USD', receiver_list, campaign=None, list=None, user=None)
|
2011-10-04 11:55:39 +00:00
|
|
|
|
|
|
|
self.validateRedirect(t, url, 2)
|
|
|
|
|
2012-03-14 22:06:29 +00:00
|
|
|
loginSandbox(self.selenium)
|
2011-10-04 11:55:39 +00:00
|
|
|
paySandbox(self, self.selenium, url)
|
|
|
|
|
|
|
|
# by now we should have received the IPN
|
2012-01-04 15:52:19 +00:00
|
|
|
# right now, for running on machine with no acess to IPN, we manually update statuses
|
|
|
|
p.checkStatus()
|
|
|
|
|
|
|
|
t = Transaction.objects.get(id=t.id)
|
|
|
|
|
2011-10-04 11:55:39 +00:00
|
|
|
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)
|
|
|
|
|
2012-01-04 15:52:19 +00:00
|
|
|
@unittest.expectedFailure
|
2011-10-04 11:55:39 +00:00
|
|
|
def test_pledge_too_much(self):
|
|
|
|
|
|
|
|
p = PaymentManager()
|
|
|
|
|
|
|
|
# Note, set this to 1-5 different receivers with absolute amounts for each
|
2012-01-04 15:52:19 +00:00
|
|
|
receiver_list = [{'email':settings.PAYPAL_GLUEJAR_EMAIL, 'amount':50000.00}]
|
2012-08-31 07:16:04 +00:00
|
|
|
t, url = p.pledge('USD', receiver_list, campaign=None, list=None, user=None)
|
2011-10-04 11:55:39 +00:00
|
|
|
|
|
|
|
self.validateRedirect(t, url, 1)
|
2012-01-04 15:52:19 +00:00
|
|
|
|
|
|
|
def tearDown(self):
|
2012-01-26 16:21:49 +00:00
|
|
|
self.selenium.quit()
|
2011-10-04 11:55:39 +00:00
|
|
|
|
|
|
|
class AuthorizeTest(TestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
self.verificationErrors = []
|
|
|
|
# This is an empty array where we will store any verification errors
|
|
|
|
# we find in our tests
|
|
|
|
|
2012-01-26 17:44:00 +00:00
|
|
|
setup_selenium()
|
2012-01-26 16:21:49 +00:00
|
|
|
self.selenium = webdriver.Firefox()
|
|
|
|
set_test_logging()
|
2011-10-04 11:55:39 +00:00
|
|
|
|
|
|
|
def validateRedirect(self, t, url):
|
|
|
|
|
|
|
|
self.assertNotEqual(url, None)
|
|
|
|
self.assertNotEqual(t, None)
|
2012-01-04 15:52:19 +00:00
|
|
|
#self.assertNotEqual(t.reference, None)
|
2011-10-04 11:55:39 +00:00
|
|
|
self.assertEqual(t.error, None)
|
|
|
|
self.assertEqual(t.status, 'NONE')
|
|
|
|
|
|
|
|
valid = URLValidator(verify_exists=True)
|
|
|
|
try:
|
|
|
|
valid(url)
|
|
|
|
except ValidationError, e:
|
|
|
|
print e
|
|
|
|
|
|
|
|
def test_authorize(self):
|
|
|
|
|
|
|
|
print "RUNNING TEST: test_authorize"
|
|
|
|
|
|
|
|
p = PaymentManager()
|
|
|
|
|
|
|
|
# Note, set this to 1-5 different receivers with absolute amounts for each
|
|
|
|
|
2012-09-07 13:45:43 +00:00
|
|
|
t, url = p.authorize(t)
|
2011-10-04 11:55:39 +00:00
|
|
|
|
|
|
|
self.validateRedirect(t, url)
|
|
|
|
|
2012-03-14 22:06:29 +00:00
|
|
|
loginSandbox(self.selenium)
|
2012-01-26 16:21:49 +00:00
|
|
|
paySandbox(self, self.selenium, url, authorize=True)
|
2011-10-04 11:55:39 +00:00
|
|
|
|
2012-01-04 15:52:19 +00:00
|
|
|
# stick in a getStatus to update statuses in the absence of IPNs
|
|
|
|
p.checkStatus()
|
|
|
|
|
2011-10-04 11:55:39 +00:00
|
|
|
t = Transaction.objects.get(id=t.id)
|
|
|
|
|
2012-03-23 18:28:09 +00:00
|
|
|
self.assertEqual(t.status, IPN_PREAPPROVAL_STATUS_ACTIVE)
|
2011-10-04 11:55:39 +00:00
|
|
|
|
2012-01-04 15:52:19 +00:00
|
|
|
def tearDown(self):
|
2012-01-26 16:21:49 +00:00
|
|
|
self.selenium.quit()
|
2012-08-07 02:52:45 +00:00
|
|
|
|
|
|
|
class CreditTest(TestCase):
|
|
|
|
user1=None
|
|
|
|
user2=None
|
|
|
|
def setUp(self):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self.user1 = User.objects.create_user('credit_test1', 'support@gluejar.com', 'credit_test1')
|
|
|
|
self.user2 = User.objects.create_user('credit_test2', 'support+1@gluejar.com', 'credit_test2')
|
|
|
|
|
|
|
|
def testSimple(self):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self.assertFalse(self.user1.credit.add_to_balance(-100))
|
|
|
|
self.assertTrue(self.user1.credit.add_to_balance(100))
|
|
|
|
self.assertTrue(self.user1.credit.add_to_pledged(50))
|
|
|
|
self.assertFalse(self.user1.credit.add_to_pledged(60))
|
|
|
|
self.assertFalse(self.user1.credit.use_pledge(60))
|
|
|
|
self.assertTrue(self.user1.credit.use_pledge(50))
|
|
|
|
self.assertFalse(self.user1.credit.transfer_to(self.user2,60))
|
|
|
|
self.assertTrue(self.user1.credit.transfer_to(self.user2,50))
|
|
|
|
self.assertEqual(self.user1.credit.balance, 0)
|
|
|
|
self.assertEqual(self.user2.credit.balance, 50)
|
|
|
|
|
|
|
|
|
2012-01-04 15:52:19 +00:00
|
|
|
|
2011-10-07 21:17:54 +00:00
|
|
|
class TransactionTest(TestCase):
|
2011-10-08 03:11:57 +00:00
|
|
|
def setUp(self):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
pass
|
2011-10-07 21:17:54 +00:00
|
|
|
def testSimple(self):
|
2011-10-08 03:11:57 +00:00
|
|
|
"""
|
2012-01-11 23:31:26 +00:00
|
|
|
create a single transaction with PAYMENT_TYPE_AUTHORIZATION / ACTIVE with a $12.34 pledge and see whether the payment
|
2011-10-08 03:11:57 +00:00
|
|
|
manager can query and get the right amount.
|
|
|
|
"""
|
2012-05-16 02:47:57 +00:00
|
|
|
user = User.objects.create_user('payment_test', 'support@gluejar.com', 'payment_test')
|
|
|
|
|
2011-10-08 03:11:57 +00:00
|
|
|
w = Work()
|
|
|
|
w.save()
|
2012-03-12 22:55:14 +00:00
|
|
|
c = Campaign(target=D('1000.00'),deadline=now() + timedelta(days=180),work=w)
|
2011-10-08 03:11:57 +00:00
|
|
|
c.save()
|
|
|
|
|
|
|
|
t = Transaction()
|
|
|
|
t.amount = D('12.34')
|
|
|
|
t.type = PAYMENT_TYPE_AUTHORIZATION
|
|
|
|
t.status = 'ACTIVE'
|
2012-01-11 23:31:26 +00:00
|
|
|
t.approved = True
|
2011-10-08 03:11:57 +00:00
|
|
|
t.campaign = c
|
2012-05-16 02:47:57 +00:00
|
|
|
t.user = user
|
2011-10-08 03:11:57 +00:00
|
|
|
t.save()
|
|
|
|
|
|
|
|
p = PaymentManager()
|
2012-06-22 03:20:32 +00:00
|
|
|
results = p.query_campaign(c,campaign_total=True, summary=False)
|
2011-10-08 03:11:57 +00:00
|
|
|
self.assertEqual(results[0].amount, D('12.34'))
|
2011-12-14 05:52:42 +00:00
|
|
|
self.assertEqual(c.left,c.target-D('12.34'))
|
2012-07-07 20:38:23 +00:00
|
|
|
self.assertEqual(c.supporters_count, 1)
|
2011-10-07 21:17:54 +00:00
|
|
|
|
2012-03-14 22:06:29 +00:00
|
|
|
class BasicGuiTest(TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.verificationErrors = []
|
|
|
|
# This is an empty array where we will store any verification errors
|
|
|
|
# we find in our tests
|
|
|
|
|
|
|
|
setup_selenium()
|
|
|
|
self.TEST_SERVER_URL = "http://ry-dev.dyndns.org"
|
|
|
|
self.selenium = webdriver.Firefox()
|
|
|
|
set_test_logging()
|
|
|
|
def testFrontPage(self):
|
|
|
|
sel = self.selenium
|
|
|
|
sel.get(self.TEST_SERVER_URL)
|
|
|
|
# if we click on the learn more, does the panel expand?
|
|
|
|
# click on a id=readon -- or the Learn More span
|
|
|
|
sel.find_elements_by_css_selector('a#readon')[0].click()
|
|
|
|
time.sleep(2.0)
|
|
|
|
# the learn more panel should be displayed
|
|
|
|
self.assertTrue(sel.find_elements_by_css_selector('div#user-block-hide')[0].is_displayed())
|
|
|
|
# click on the panel again -- and panel should not be displayed
|
|
|
|
sel.find_elements_by_css_selector('a#readon')[0].click()
|
|
|
|
time.sleep(2.0)
|
|
|
|
self.assertFalse(sel.find_elements_by_css_selector('div#user-block-hide')[0].is_displayed())
|
|
|
|
def tearDown(self):
|
|
|
|
self.selenium.quit()
|
|
|
|
|
|
|
|
|
2011-10-07 21:17:54 +00:00
|
|
|
def suite():
|
|
|
|
|
2012-01-04 15:52:19 +00:00
|
|
|
#testcases = [PledgeTest, AuthorizeTest, TransactionTest]
|
2012-08-31 07:16:04 +00:00
|
|
|
testcases = [TransactionTest, CreditTest]
|
2011-10-07 21:17:54 +00:00
|
|
|
suites = unittest.TestSuite([unittest.TestLoader().loadTestsFromTestCase(testcase) for testcase in testcases])
|
|
|
|
return suites
|
2011-10-04 11:55:39 +00:00
|
|
|
|
2012-01-26 17:44:00 +00:00
|
|
|
|