mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-19 10:19:27 -05:00
Enable some testing against a real email server to hopefully catch things earlier
This commit is contained in:
parent
55089aab32
commit
97ceb1a8a6
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@ -92,7 +92,12 @@ jobs:
|
|||||||
ports:
|
ports:
|
||||||
- "3000:3000/tcp"
|
- "3000:3000/tcp"
|
||||||
env:
|
env:
|
||||||
|
# Enable Tika end to end testing
|
||||||
TIKA_LIVE: 1
|
TIKA_LIVE: 1
|
||||||
|
# Enable paperless_mail testing against real server
|
||||||
|
PAPERLESS_MAIL_TEST_HOST: ${{ secrets.TEST_MAIL_HOST }}
|
||||||
|
PAPERLESS_MAIL_TEST_USER: ${{ secrets.TEST_MAIL_USER }}
|
||||||
|
PAPERLESS_MAIL_TEST_PASSWD: ${{ secrets.TEST_MAIL_PASSWD }}
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
|
70
src/paperless_mail/tests/test_live_mail.py
Normal file
70
src/paperless_mail/tests/test_live_mail.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from django.test import TestCase
|
||||||
|
from paperless_mail.mail import MailAccountHandler
|
||||||
|
from paperless_mail.mail import MailError
|
||||||
|
from paperless_mail.models import MailAccount
|
||||||
|
from paperless_mail.models import MailRule
|
||||||
|
|
||||||
|
# Only run if the environment is setup
|
||||||
|
# And the environment is not empty (forks, I think)
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
"PAPERLESS_MAIL_TEST_HOST" not in os.environ
|
||||||
|
or not len(os.environ["PAPERLESS_MAIL_TEST_HOST"]),
|
||||||
|
reason="Live server testing not enabled",
|
||||||
|
)
|
||||||
|
class TestMailLiveServer(TestCase):
|
||||||
|
def setUp(self) -> None:
|
||||||
|
|
||||||
|
self.mail_account_handler = MailAccountHandler()
|
||||||
|
self.account = MailAccount.objects.create(
|
||||||
|
name="test",
|
||||||
|
imap_server=os.environ["PAPERLESS_MAIL_TEST_HOST"],
|
||||||
|
username=os.environ["PAPERLESS_MAIL_TEST_USER"],
|
||||||
|
password=os.environ["PAPERLESS_MAIL_TEST_PASSWD"],
|
||||||
|
imap_port=993,
|
||||||
|
)
|
||||||
|
|
||||||
|
return super().setUp()
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
self.account.delete()
|
||||||
|
return super().tearDown()
|
||||||
|
|
||||||
|
def test_process_non_gmail_server_flag(self):
|
||||||
|
|
||||||
|
try:
|
||||||
|
rule1 = MailRule.objects.create(
|
||||||
|
name="testrule",
|
||||||
|
account=self.account,
|
||||||
|
action=MailRule.MailAction.FLAG,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.mail_account_handler.handle_mail_account(self.account)
|
||||||
|
|
||||||
|
rule1.delete()
|
||||||
|
|
||||||
|
except MailError as e:
|
||||||
|
self.fail(f"Failure: {e}")
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_process_non_gmail_server_tag(self):
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
rule2 = MailRule.objects.create(
|
||||||
|
name="testrule",
|
||||||
|
account=self.account,
|
||||||
|
action=MailRule.MailAction.TAG,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.mail_account_handler.handle_mail_account(self.account)
|
||||||
|
|
||||||
|
rule2.delete()
|
||||||
|
|
||||||
|
except MailError as e:
|
||||||
|
self.fail(f"Failure: {e}")
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
Loading…
x
Reference in New Issue
Block a user