Source code for mail_deduplicate.tests.test_cli

# Copyright Kevin Deldycke <kevin@deldycke.com> and contributors.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
from __future__ import annotations

from mailbox import Maildir


[docs]def test_bare_call(invoke): result = invoke() assert result.exit_code == 0 assert "Usage:" in result.stdout
[docs]def test_early_export_file_check(invoke, make_box, tmp_path): """Ensures the export file is tested for existence before any process is ran. See: https://github.com/kdeldycke/mail-deduplicate/issues/119 """ box_path, _ = make_box(Maildir) result = invoke("--export=non_existing.file", box_path) assert result.exit_code == 0 assert "0 mails found." in result.stderr assert "● Step #1" in result.stdout assert "non_existing.file" not in result.stderr file = tmp_path.joinpath("existing.file") file.touch() result = invoke(f"--export={file!s}", box_path) assert result.exit_code == 1 assert result.stderr == "" assert str(result.exception) == str(file)