get rid of AccountTest0
renamed notice to Credit Card Number Updated actually save account in update_account_statuspull/1/head
parent
31b978bb25
commit
a3cc502924
|
@ -106,7 +106,7 @@ def create_notice_types(app, created_models, verbosity, **kwargs):
|
||||||
notification.create_notice_type("new_wisher", _("New wisher"), _("Someone new has wished for a book that you're the rightsholder for"))
|
notification.create_notice_type("new_wisher", _("New wisher"), _("Someone new has wished for a book that you're the rightsholder for"))
|
||||||
notification.create_notice_type("account_expiring", _("Credit Card Expiring Soon"), _("Your credit card is about to expire."))
|
notification.create_notice_type("account_expiring", _("Credit Card Expiring Soon"), _("Your credit card is about to expire."))
|
||||||
notification.create_notice_type("account_expired", _("Credit Card Has Expired"), _("Your credit card has expired."))
|
notification.create_notice_type("account_expired", _("Credit Card Has Expired"), _("Your credit card has expired."))
|
||||||
notification.create_notice_type("account_active", _("Credit Card Number Noted"), _("Payment method updated."), default = 1)
|
notification.create_notice_type("account_active", _("Credit Card Number Updated"), _("Payment method updated."), default = 1)
|
||||||
|
|
||||||
signals.post_syncdb.connect(create_notice_types, sender=notification)
|
signals.post_syncdb.connect(create_notice_types, sender=notification)
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ def update_account_status():
|
||||||
for account in Account.objects.all():
|
for account in Account.objects.all():
|
||||||
try:
|
try:
|
||||||
account.status = account.calculated_status()
|
account.status = account.calculated_status()
|
||||||
|
account.save()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
errors.append(e)
|
errors.append(e)
|
||||||
|
|
||||||
|
|
|
@ -347,9 +347,6 @@ class Account(models.Model):
|
||||||
def calculated_status(self):
|
def calculated_status(self):
|
||||||
"""returns ACTIVE, DEACTIVATED, EXPIRED, EXPIRING, or ERROR"""
|
"""returns ACTIVE, DEACTIVATED, EXPIRED, EXPIRING, or ERROR"""
|
||||||
|
|
||||||
# TO DO: integrate this method in to see whether we are using the right range of values
|
|
||||||
# also, cache this status by having a value in the db in the future.
|
|
||||||
|
|
||||||
# is it deactivated?
|
# is it deactivated?
|
||||||
|
|
||||||
today = date_today()
|
today = date_today()
|
||||||
|
|
|
@ -421,94 +421,6 @@ class AccountTest(TestCase):
|
||||||
user1.delete()
|
user1.delete()
|
||||||
account1.delete()
|
account1.delete()
|
||||||
|
|
||||||
class AccountTest0(TestCase):
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
# create a user
|
|
||||||
|
|
||||||
print "in setUpClass..."
|
|
||||||
|
|
||||||
print AccountTest.get_transaction_level()
|
|
||||||
|
|
||||||
cls.user1 = User.objects.create_user('account_test1', 'account_test1@gluejar.com', 'account_test1_pw')
|
|
||||||
cls.user1.save()
|
|
||||||
|
|
||||||
cls.account1 = Account(host='host1', account_id='1', user=cls.user1, status='ACTIVE')
|
|
||||||
cls.account1.save()
|
|
||||||
|
|
||||||
# look at what profiles exist
|
|
||||||
from regluit.core.models import UserProfile
|
|
||||||
print "number of UserProfile in setUpClass ", UserProfile.objects.count()
|
|
||||||
for profile in UserProfile.objects.all():
|
|
||||||
print profile.id, profile.user
|
|
||||||
|
|
||||||
|
|
||||||
# check that user1, account1 exist and accessible via profile
|
|
||||||
user = User.objects.all()[0]
|
|
||||||
print user
|
|
||||||
try:
|
|
||||||
print "user.profile.id", user.profile.id, user.profile.user
|
|
||||||
except Exception as e:
|
|
||||||
print e
|
|
||||||
|
|
||||||
# print out isolation level
|
|
||||||
# https://docs.djangoproject.com/en/dev/topics/db/sql/
|
|
||||||
# http://stackoverflow.com/questions/5347567/view-isolation-level-for-a-query-in-mysql#comment6039450_5347676
|
|
||||||
|
|
||||||
@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):
|
|
||||||
|
|
||||||
print "in test_status_changes...."
|
|
||||||
|
|
||||||
print "AccountTest.user1.id", AccountTest.user1.id
|
|
||||||
|
|
||||||
# look at what profiles exist
|
|
||||||
from regluit.core.models import UserProfile
|
|
||||||
print "number of UserProfile in test_status_changes", UserProfile.objects.count()
|
|
||||||
|
|
||||||
for profile in UserProfile.objects.all():
|
|
||||||
print profile.id, profile.user
|
|
||||||
|
|
||||||
try:
|
|
||||||
print "AccountTest.user1.profile", AccountTest.user1.profile.id
|
|
||||||
except Exception as e:
|
|
||||||
print e
|
|
||||||
|
|
||||||
account = AccountTest.user1.profile.account
|
|
||||||
self.assertEqual(account.status, 'ACTIVE')
|
|
||||||
account.status = 'EXPIRING'
|
|
||||||
account.save()
|
|
||||||
|
|
||||||
self.assertEqual(account.status, 'EXPIRING')
|
|
||||||
account.status = 'EXPIRED'
|
|
||||||
account.save()
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def tearDownClass(cls):
|
|
||||||
|
|
||||||
print "in tearDownClass..."
|
|
||||||
|
|
||||||
from notification.models import Notice
|
|
||||||
from django.core import mail
|
|
||||||
|
|
||||||
print len(mail.outbox)
|
|
||||||
for (i, m) in enumerate(mail.outbox):
|
|
||||||
print i, m.subject, m.body
|
|
||||||
|
|
||||||
print [(n.id, n.notice_type.label, n.recipient, n.added) for n in Notice.objects.all()]
|
|
||||||
|
|
||||||
cls.user1.delete()
|
|
||||||
cls.account1.delete()
|
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
|
|
||||||
#testcases = [PledgeTest, AuthorizeTest, TransactionTest]
|
#testcases = [PledgeTest, AuthorizeTest, TransactionTest]
|
||||||
|
|
Loading…
Reference in New Issue