From 270910f6be6697ed3e3415836137d6e03634a015 Mon Sep 17 00:00:00 2001 From: s3lph Date: Sun, 9 Sep 2018 04:01:33 +0200 Subject: [PATCH] Removed debug output. --- matemat/db/facade.py | 8 +------- matemat/db/test/test_facade.py | 19 ++++++++----------- .../webserver/pagelets/receipt_smtp_cron.py | 2 +- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/matemat/db/facade.py b/matemat/db/facade.py index 4447b39..2251427 100644 --- a/matemat/db/facade.py +++ b/matemat/db/facade.py @@ -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: diff --git a/matemat/db/test/test_facade.py b/matemat/db/test/test_facade.py index 5441c00..16e9b86 100644 --- a/matemat/db/test/test_facade.py +++ b/matemat/db/test/test_facade.py @@ -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: diff --git a/matemat/webserver/pagelets/receipt_smtp_cron.py b/matemat/webserver/pagelets/receipt_smtp_cron.py index ad03c71..0df5d77 100644 --- a/matemat/webserver/pagelets/receipt_smtp_cron.py +++ b/matemat/webserver/pagelets/receipt_smtp_cron.py @@ -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)