add imap_ssl_email_client fixture
This commit is contained in:
parent
bf60b4b452
commit
843d971916
1 changed files with 17 additions and 0 deletions
|
|
@ -5,6 +5,8 @@
|
||||||
# sys.path. It is thus good practise for projects to either put conftest.py under
|
# sys.path. It is thus good practise for projects to either put conftest.py under
|
||||||
# a package scope or to never import anything from a conftest.py file.
|
# a package scope or to never import anything from a conftest.py file.
|
||||||
|
|
||||||
|
import os
|
||||||
|
from imaplib import IMAP4_SSL
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
@ -69,3 +71,18 @@ def dotenv_config(request) -> dict[str, str]:
|
||||||
dotenv_path = Path(dotenv_path)
|
dotenv_path = Path(dotenv_path)
|
||||||
assert dotenv_path.is_file()
|
assert dotenv_path.is_file()
|
||||||
return dotenv_values(dotenv_path) # type: ignore
|
return dotenv_values(dotenv_path) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def imap_ssl_email_client() -> None:
|
||||||
|
assert os.environ["IMAP_HOST"]
|
||||||
|
assert os.environ["IMAP_PORT"]
|
||||||
|
assert os.environ["IMAP_USER"]
|
||||||
|
assert os.environ["IMAP_PASS"]
|
||||||
|
port = int(os.environ["IMAP_PORT"])
|
||||||
|
imap_client = IMAP4_SSL(host=os.environ["IMAP_HOST"], port=port)
|
||||||
|
imap_client.login(os.environ["IMAP_USER"], os.environ["IMAP_PASS"])
|
||||||
|
imap_client.select("INBOX")
|
||||||
|
yield imap_client
|
||||||
|
imap_client.close()
|
||||||
|
imap_client.logout()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue