From 61723528f220ce939a207d8f58a87a21927cb820 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 5 Oct 2024 07:41:59 -0700 Subject: [PATCH] Fix tests --- src/documents/tests/test_migration_workflows.py | 2 +- src/paperless_mail/mail.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/documents/tests/test_migration_workflows.py b/src/documents/tests/test_migration_workflows.py index 81bb577b2..34e2afb5b 100644 --- a/src/documents/tests/test_migration_workflows.py +++ b/src/documents/tests/test_migration_workflows.py @@ -8,7 +8,7 @@ class TestMigrateWorkflow(TestMigrations): dependencies = ( ( "paperless_mail", - "0026_mailrule_enabled", + "0027_mailaccount_expiration_mailaccount_refresh_token", ), ) diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index b86414674..16f7e3634 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -572,7 +572,11 @@ class MailAccountHandler(LoggingMixin): account.imap_port, account.imap_security, ) as M: - if account.is_token and account.expiration < timezone.now(): + if ( + account.is_token + and account.expiration is not None + and account.expiration < timezone.now() + ): self.log.debug(f"Attempting to refresh token for account {account}") success = self.refresh_token(account) if not success: