Skip to content

Commit

Permalink
Cover a line in MailboxSender
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Mar 7, 2021
1 parent fab33b7 commit 19792fc
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/test_senders/test_babyl.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,18 @@ def test_babyl_send_no_context(
inbox.close()
assert len(msgs) == 1
assert email2dict(test_email1) == email2dict(msgs[0])


def test_babyl_close_unopened(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
monkeypatch.chdir(tmp_path)
sender = from_dict(
{
"method": "babyl",
"path": "inbox",
},
configpath=str(tmp_path / "foo.txt"),
)
assert isinstance(sender, BabylSender)
with pytest.raises(ValueError) as excinfo:
sender.close()
assert str(excinfo.value) == "Mailbox is not open"
17 changes: 17 additions & 0 deletions test/test_senders/test_maildir.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,20 @@ def test_maildir_send_no_context(
msgs = list(inbox)
assert len(msgs) == 1
assert email2dict(test_email1) == email2dict(msgs[0])


def test_maildir_close_unopened(
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
monkeypatch.chdir(tmp_path)
sender = from_dict(
{
"method": "maildir",
"path": "inbox",
},
configpath=str(tmp_path / "foo.txt"),
)
assert isinstance(sender, MaildirSender)
with pytest.raises(ValueError) as excinfo:
sender.close()
assert str(excinfo.value) == "Mailbox is not open"
15 changes: 15 additions & 0 deletions test/test_senders/test_mbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,18 @@ def test_mbox_send_no_context(
msgdict = email2dict(msgs[0])
msgdict["unixfrom"] = None
assert email2dict(test_email1) == msgdict


def test_mbox_close_unopened(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
monkeypatch.chdir(tmp_path)
sender = from_dict(
{
"method": "mbox",
"path": "inbox",
},
configpath=str(tmp_path / "foo.txt"),
)
assert isinstance(sender, MboxSender)
with pytest.raises(ValueError) as excinfo:
sender.close()
assert str(excinfo.value) == "Mailbox is not open"
15 changes: 15 additions & 0 deletions test/test_senders/test_mh.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,18 @@ def test_mh_send_no_context(
msgs = list(inbox)
assert len(msgs) == 1
assert email2dict(test_email1) == email2dict(msgs[0])


def test_mh_close_unopened(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
monkeypatch.chdir(tmp_path)
sender = from_dict(
{
"method": "mh",
"path": "inbox",
},
configpath=str(tmp_path / "foo.txt"),
)
assert isinstance(sender, MHSender)
with pytest.raises(ValueError) as excinfo:
sender.close()
assert str(excinfo.value) == "Mailbox is not open"
15 changes: 15 additions & 0 deletions test/test_senders/test_mmdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,18 @@ def test_mmdf_send_no_context(
msgdict = email2dict(msgs[0])
msgdict["unixfrom"] = None
assert email2dict(test_email1) == msgdict


def test_mmdf_close_unopened(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
monkeypatch.chdir(tmp_path)
sender = from_dict(
{
"method": "mmdf",
"path": "inbox",
},
configpath=str(tmp_path / "foo.txt"),
)
assert isinstance(sender, MMDFSender)
with pytest.raises(ValueError) as excinfo:
sender.close()
assert str(excinfo.value) == "Mailbox is not open"

0 comments on commit 19792fc

Please sign in to comment.