2011-09-27 12:48:11 +00:00
|
|
|
"""
|
2013-06-03 16:31:39 +00:00
|
|
|
external library imports
|
2011-09-27 12:48:11 +00:00
|
|
|
"""
|
2013-06-03 16:31:39 +00:00
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import time
|
|
|
|
import traceback
|
2018-04-20 01:26:29 +00:00
|
|
|
import unittest
|
2011-09-27 12:48:11 +00:00
|
|
|
|
2013-06-03 16:31:39 +00:00
|
|
|
from datetime import timedelta
|
|
|
|
from decimal import Decimal as D
|
|
|
|
from selenium import webdriver
|
|
|
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
|
|
|
|
|
|
"""
|
|
|
|
django imports
|
|
|
|
"""
|
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
|
2013-06-03 16:31:39 +00:00
|
|
|
from django.core.exceptions import ValidationError
|
|
|
|
from django.core.validators import URLValidator
|
|
|
|
from django.test import TestCase
|
2018-04-19 16:24:34 +00:00
|
|
|
from django.utils.timezone import now
|
2013-06-03 16:31:39 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
regluit imports
|
|
|
|
"""
|
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
|
2013-06-03 16:31:39 +00:00
|
|
|
from regluit.payment.manager import PaymentManager
|
|
|
|
from regluit.payment.models import Transaction, Account
|
2011-10-04 11:55:39 +00:00
|
|
|
from regluit.payment.parameters import *
|
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
|
|
|
|
2020-02-12 15:43:41 +00:00
|
|
|
print("LOGIN SANDBOX")
|
2011-10-04 11:55:39 +00:00
|
|
|
|
|
|
|
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:
|
2020-02-12 15:43:41 +00:00
|
|
|
print("AUTHORIZE SANDBOX")
|
2012-01-26 16:21:49 +00:00
|
|
|
else:
|
2020-02-12 15:43:41 +00:00
|
|
|
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)
|
2020-02-12 15:43:41 +00:00
|
|
|
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:
|
2020-02-12 15:43:41 +00:00
|
|
|
print("Ready for Login")
|
2012-01-26 19:50:14 +00:00
|
|
|
|
|
|
|
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()
|
|
|
|
|
2020-02-12 15:43:41 +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
|
|
|
|
2020-02-12 15:43:41 +00:00
|
|
|
print("Expected title: {0} \n Actual Title: {1}".format('Amazon.com Sign In', sel.title))
|
2012-05-18 22:06:35 +00:00
|
|
|
# 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']")
|
2020-02-12 15:43:41 +00:00
|
|
|
print("Expected title: {0} \n Actual Title: {1}".format('Amazon Payments', sel.title))
|
|
|
|
print ("looking for credit_card_confirm", sel.current_url)
|
2012-04-25 20:10:53 +00:00
|
|
|
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()
|
2016-04-19 14:49:20 +00:00
|
|
|
|
|
|
|
@unittest.skip("skipping PledgeTest (selenium)")
|
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:
|
2020-02-12 15:43:41 +00:00
|
|
|
print(e)
|
2012-01-04 15:52:19 +00:00
|
|
|
|
|
|
|
def tearDown(self):
|
2012-01-26 16:21:49 +00:00
|
|
|
self.selenium.quit()
|
2016-04-19 14:49:20 +00:00
|
|
|
|
|
|
|
@unittest.skip("skipping AuthorizeTest (selenium)")
|
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:
|
2020-02-12 15:43:41 +00:00
|
|
|
print(e)
|
2011-10-04 11:55:39 +00:00
|
|
|
|
|
|
|
def test_authorize(self):
|
|
|
|
|
2020-02-12 15:43:41 +00:00
|
|
|
print("RUNNING TEST: test_authorize")
|
2011-10-04 11:55:39 +00:00
|
|
|
|
|
|
|
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):
|
|
|
|
"""
|
|
|
|
"""
|
2013-03-06 14:39:06 +00:00
|
|
|
self.user1 = User.objects.create_user('credit_test1', 'support@example.org', 'credit_test1')
|
|
|
|
self.user2 = User.objects.create_user('credit_test2', 'support+1@example.org', 'credit_test2')
|
2012-08-07 02:52:45 +00:00
|
|
|
|
|
|
|
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)
|
2013-08-18 19:21:55 +00:00
|
|
|
|
2016-04-19 14:49:20 +00:00
|
|
|
@unittest.skip("skipping ExtraTest")
|
2013-08-18 19:21:55 +00:00
|
|
|
class ExtraTest(TestCase):
|
|
|
|
|
|
|
|
def testPledgeExtra(self):
|
|
|
|
u= User.objects.create_user('payment_test', 'support@example.org', 'payment_test')
|
|
|
|
t= Transaction(user=u)
|
|
|
|
self.assertEqual(t.extra, {})
|
|
|
|
ack_name=t.extra.get('ack_name','')
|
|
|
|
if not ack_name:
|
|
|
|
t.extra.update({'ack_name': t.user.username})
|
|
|
|
self.assertEqual(t.extra, {'ack_name': 'payment_test'})
|
|
|
|
|
2012-08-07 02:52:45 +00:00
|
|
|
|
2011-10-07 21:17:54 +00:00
|
|
|
class TransactionTest(TestCase):
|
2016-04-09 17:21:12 +00:00
|
|
|
fixtures=['initial_data.json']
|
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.
|
|
|
|
"""
|
2013-03-06 14:39:06 +00:00
|
|
|
user = User.objects.create_user('payment_test', 'support@example.org', 'payment_test')
|
2012-05-16 02:47:57 +00:00
|
|
|
|
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()
|
|
|
|
|
2012-10-03 12:57:24 +00:00
|
|
|
#test pledge adders
|
|
|
|
user.profile.reset_pledge_badge()
|
|
|
|
self.assertEqual(user.profile.badges.all()[0].name,'pledger')
|
|
|
|
|
2011-10-08 03:11:57 +00:00
|
|
|
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)
|
2013-06-28 23:05:19 +00:00
|
|
|
|
|
|
|
def test_paymentmanager_charge(self):
|
|
|
|
"""
|
|
|
|
test regluit.payment.manager.PaymentManager.charge
|
|
|
|
|
|
|
|
trying to simulate the conditions of having a bare transaction setup before we try to do
|
|
|
|
an instant charge.
|
|
|
|
|
|
|
|
"""
|
|
|
|
user = User.objects.create_user('pm_charge', 'support2@example.org', 'payment_test')
|
|
|
|
# need to create an Account to associate with user
|
|
|
|
from regluit.payment.stripelib import StripeClient, card, Processor
|
|
|
|
|
|
|
|
sc = StripeClient()
|
|
|
|
|
|
|
|
# valid card and Account
|
|
|
|
card0 = card()
|
|
|
|
stripe_processor = Processor()
|
2014-02-20 20:56:10 +00:00
|
|
|
account = stripe_processor.make_account(user=user,token=card0)
|
2013-06-28 23:05:19 +00:00
|
|
|
|
|
|
|
w = Work()
|
|
|
|
w.save()
|
|
|
|
|
|
|
|
c = Campaign(target=D('1000.00'),deadline=now() + timedelta(days=180),work=w)
|
|
|
|
c.save()
|
|
|
|
|
|
|
|
t = Transaction(host='stripelib')
|
|
|
|
|
|
|
|
t.max_amount = D('12.34')
|
|
|
|
t.type = PAYMENT_TYPE_NONE
|
|
|
|
t.status = TRANSACTION_STATUS_NONE
|
|
|
|
t.campaign = c
|
|
|
|
t.approved = False
|
|
|
|
t.user = user
|
|
|
|
|
|
|
|
t.save()
|
|
|
|
|
|
|
|
pm = PaymentManager()
|
|
|
|
response = pm.charge(t)
|
|
|
|
|
|
|
|
self.assertEqual(t.status, TRANSACTION_STATUS_COMPLETE)
|
|
|
|
self.assertEqual(t.type, EXECUTE_TYPE_CHAINED_INSTANT)
|
|
|
|
self.assertEqual(t.amount, D('12.34'))
|
2011-10-07 21:17:54 +00:00
|
|
|
|
2016-04-12 17:48:04 +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
|
2012-03-14 22:06:29 +00:00
|
|
|
|
2016-04-12 17:48:04 +00:00
|
|
|
# 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()
|
2013-04-12 18:13:26 +00:00
|
|
|
|
|
|
|
|
2012-10-11 23:36:24 +00:00
|
|
|
class AccountTest(TestCase):
|
|
|
|
|
2013-04-12 18:13:26 +00:00
|
|
|
@staticmethod
|
|
|
|
def get_transaction_level():
|
|
|
|
from django.db import connection
|
|
|
|
cursor = connection.cursor()
|
|
|
|
|
|
|
|
cursor.execute("SELECT * FROM information_schema.global_variables WHERE variable_name='tx_isolation';")
|
|
|
|
row = cursor.fetchone()
|
|
|
|
return row
|
|
|
|
|
|
|
|
|
|
|
|
def test_status_changes(self):
|
|
|
|
|
|
|
|
from regluit.core.models import UserProfile
|
|
|
|
|
|
|
|
user1 = User.objects.create_user('account_test1', 'account_test1@gluejar.com', 'account_test1_pw')
|
|
|
|
user1.save()
|
|
|
|
|
|
|
|
account1 = Account(host='host1', account_id='1', user=user1, status='ACTIVE')
|
|
|
|
account1.save()
|
2013-05-09 01:15:33 +00:00
|
|
|
|
|
|
|
user = User.objects.all()[0]
|
2013-04-12 18:13:26 +00:00
|
|
|
|
|
|
|
account = user1.profile.account
|
|
|
|
self.assertEqual(account.status, 'ACTIVE')
|
|
|
|
account.status = 'EXPIRING'
|
|
|
|
account.save()
|
|
|
|
|
|
|
|
self.assertEqual(account.status, 'EXPIRING')
|
|
|
|
account.save()
|
|
|
|
|
|
|
|
user1.delete()
|
|
|
|
account1.delete()
|
|
|
|
|
2011-10-07 21:17:54 +00:00
|
|
|
def suite():
|
|
|
|
|
2012-01-04 15:52:19 +00:00
|
|
|
#testcases = [PledgeTest, AuthorizeTest, TransactionTest]
|
2013-03-04 19:19:13 +00:00
|
|
|
testcases = [TransactionTest, CreditTest, AccountTest]
|
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
|
|
|
|