Removed debug output.

This commit is contained in:
s3lph 2018-09-09 04:01:33 +02:00
parent a8e0687095
commit 270910f6be
3 changed files with 10 additions and 19 deletions

View file

@ -585,12 +585,10 @@ class MatematDatabase(object):
# Reflect the change in the user object
user.balance = old_balance + amount
def check_receipt_due(self, user: User, logger: logging.Logger) -> bool:
def check_receipt_due(self, user: User) -> bool:
if not isinstance(user.receipt_pref, ReceiptPreference):
raise TypeError()
logger.debug('User: "%s", receipt_preference: %s, e-mail: %s.', user.name, user.receipt_pref, user.email)
if user.receipt_pref == ReceiptPreference.NONE or user.email is None:
logger.debug('Receipt preference None or no e-mail.')
return False
with self.db.transaction() as c:
c.execute('''
@ -603,10 +601,6 @@ class MatematDatabase(object):
last_receipt: datetime = datetime.fromtimestamp(c.fetchone()[0])
next_receipt_due: datetime = user.receipt_pref.next_receipt_due(last_receipt)
logger.debug('Last receipt: %s.', last_receipt)
logger.debug('Next receipt: %s.', next_receipt_due)
logger.debug('Now: %s.', datetime.utcnow())
return datetime.utcnow() > next_receipt_due
def create_receipt(self, user: User, write: bool = False) -> Receipt:

View file

@ -482,18 +482,15 @@ class DatabaseTest(unittest.TestCase):
'user6': user6.id
})
import logging
logger = logging.getLogger('test')
self.assertFalse(db.check_receipt_due(user0, logger))
self.assertFalse(self.db.check_receipt_due(user1, logger))
self.assertTrue(self.db.check_receipt_due(user2, logger))
self.assertTrue(self.db.check_receipt_due(user3, logger))
self.assertFalse(self.db.check_receipt_due(user4, logger))
self.assertTrue(self.db.check_receipt_due(user5, logger))
self.assertFalse(self.db.check_receipt_due(user6, logger))
self.assertFalse(db.check_receipt_due(user0))
self.assertFalse(self.db.check_receipt_due(user1))
self.assertTrue(self.db.check_receipt_due(user2))
self.assertTrue(self.db.check_receipt_due(user3))
self.assertFalse(self.db.check_receipt_due(user4))
self.assertTrue(self.db.check_receipt_due(user5))
self.assertFalse(self.db.check_receipt_due(user6))
with self.assertRaises(TypeError):
self.db.check_receipt_due(user7, logger)
self.db.check_receipt_due(user7)
def test_create_receipt(self):
with self.db as db:

View file

@ -28,7 +28,7 @@ def receipt_smtp_cron(config: Dict[str, str],
for user in users:
if user.email is None:
logger.debug('User "%s" has no e-mail address.', user.name)
if db.check_receipt_due(user, logger):
if db.check_receipt_due(user):
logger.info('Generating receipt for user "%s".', user.name)
# Generate receipts that are due
receipt: Receipt = db.create_receipt(user, write=True)