mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-17 11:26:13 +02:00
update tests and imports for removal of _export_journal
This commit is contained in:
parent
b1adedb575
commit
77ac858aad
2 changed files with 5 additions and 25 deletions
|
@ -2,12 +2,12 @@ import argparse
|
|||
import jrnl
|
||||
import pytest
|
||||
from unittest import mock
|
||||
from jrnl.jrnl import _display_search_results, _export_journal
|
||||
from jrnl.jrnl import _display_search_results
|
||||
|
||||
|
||||
# fmt: off
|
||||
# see: https://github.com/psf/black/issues/664
|
||||
@pytest.mark.parametrize("export_format", [ "pretty", "short",])
|
||||
@pytest.mark.parametrize("export_format", [ "pretty", "short","markdown"])
|
||||
#fmt: on
|
||||
@mock.patch.object(argparse, "Namespace", return_value={"export": "markdown", "filename": "irrele.vant"})
|
||||
def test_export_format(mock_args, export_format):
|
||||
|
@ -21,22 +21,3 @@ def test_export_format(mock_args, export_format):
|
|||
_display_search_results(mock_args, test_journal)
|
||||
mock_spy_print.assert_called_once_with(mock_pprint())
|
||||
#fmt: on
|
||||
|
||||
|
||||
@mock.patch.object(argparse, "Namespace", return_value={"export": "markdown", "filename": "foo.jrnl"})
|
||||
def test_export_plugin(mock_args):
|
||||
export_format = mock_args.return_value["export"]
|
||||
|
||||
test_journal = jrnl.Journal.Journal
|
||||
mock_args.export = export_format
|
||||
mock_args.filename = mock_args.return_value['filename']
|
||||
|
||||
# fmt: off
|
||||
# see: https://github.com/psf/black/issues/664
|
||||
with mock.patch("builtins.print") as print_spy, \
|
||||
mock.patch("jrnl.plugins.get_exporter") as mock_get_exporter, \
|
||||
mock.patch("jrnl.Journal.Journal.pprint") :
|
||||
_export_journal(mock_args, test_journal)
|
||||
# fmt: on
|
||||
mock_get_exporter.assert_called_once_with(export_format)
|
||||
print_spy.assert_called_once_with(mock_get_exporter().export(test_journal,mock_args.filename))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue