mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
* behavior outline
* FIrst pass at allow external plugins
* remove template exporter
* Add listing of active plugins to '--version' output
* Documentation for plugins
* [Docs] add custom imports and exporters to site TOC
* [Docs] better linewrapping
* enforce positive initial linewrap
Check column widths
update gitignore
throw error when linewrap too small
simply check for large enough linewrap value
* delete unused error message
* PR feedback
make exception more informative
update check_linewrap signature in src and test
make check_linewrap a free function
* delete unused function
* delete else..pass block
* newline for make format
* Include dates_exporter
* Use Base classes for importer and exporters.
* [Docs] improve documentation of custom Importers and Exporters
* [Testing] separate run with external plugin!
* basic behavior test
* prototype unittest for JSON Exporter
test for unimplemented method
* make format
delete unused imports
* Remove 'importer' or 'exporter' from filenames where not needed
* [Test] run different tests with or without the external plugins installed
* [Test] move test rot13 plugin into git tree
from 0dc912af82
* consolidate demo plugins to common package
* [Docs] name page for plugins
* [Docs] include the sample plug in code files directly
* style fixes
* [test] determine whether to run external plug in tests based on installed packages
* improved code documentation
* style fixes for GitHub actions
* Convert "short" and "pretty" (and "default") formaters to plugins
further to https://github.com/jrnl-org/jrnl/pull/1177
* more code clean up
tests pass locally...now for GitHub...
* [tests] dynamically determine jrnl version for plugin tests
* [GitHub Actions] direct install of testing plugins
* Remove template code
* [plugins] meta --> collector
* [Docs] create scripted entries using an custom importer
* (closer to) being able to run behave tests outside project root directory
* We already know when exporter to use
Don't re-calculate it!
* [Tests] don't name test plugin 'testing"
If so named, pip won't install it.
* [Test] run behave tests with test plugins outside project root
* [Test] behave tests pass locally
* [Docs] fix typo
* [GitHub Actions] run test commands from poetry's shell
* black-ify code
* [GitHub Actions] move downstream (rather than up) to run tests
* [GitHub Actions] set shell to poetry
* [GitHub Workflows] Manually activate virtual environment
* [GitHub Actions] Skip Windows & Python 3.8
Can't seem to find Python exe?
* [GiotHub Actions] explicitly use virtual env
* [GitHub Actions] create virutal env directly
* [GitHub Actions] better activate of Windows virtual env
* [GitHub Actions] create virtual env on Mac
* [Github Actions] install wheel and upgrade pip
* [GitHub Actions] skip virtual environments altogether
* [GitHub Actions] change directory for behave test
* Remove Windows exclusions from CI as per note -- they should be working now
Co-authored-by: Suhas <sugas182@gmail.com>
Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
77 lines
2.9 KiB
Python
77 lines
2.9 KiB
Python
from unittest import mock
|
|
|
|
from behave import then
|
|
|
|
from jrnl.args import parse_args
|
|
from jrnl.behave_testing import _mock_getpass
|
|
from jrnl.behave_testing import _mock_time_parse
|
|
from jrnl.jrnl import run
|
|
|
|
|
|
@then("the editor {editor} should have been called")
|
|
@then("No editor should have been called")
|
|
def editor_override(context, editor=None):
|
|
def _mock_write_in_editor(config):
|
|
editor = config["editor"]
|
|
journal = "features/journals/journal.jrnl"
|
|
context.tmpfile = journal
|
|
print("%s has been launched" % editor)
|
|
return journal
|
|
|
|
if "password" in context:
|
|
password = context.password
|
|
else:
|
|
password = ""
|
|
# fmt: off
|
|
# see: https://github.com/psf/black/issues/664
|
|
with \
|
|
mock.patch("jrnl.jrnl._write_in_editor", side_effect=_mock_write_in_editor(context.jrnl_config)) as mock_write_in_editor, \
|
|
mock.patch("sys.stdin.isatty", return_value=True), \
|
|
mock.patch('getpass.getpass',side_effect=_mock_getpass(password)), \
|
|
mock.patch("jrnl.time.parse", side_effect = _mock_time_parse(context)), \
|
|
mock.patch("jrnl.config.get_config_path", side_effect=lambda: context.config_path), \
|
|
mock.patch("jrnl.install.get_config_path", side_effect=lambda: context.config_path) \
|
|
:
|
|
try :
|
|
parsed_args = parse_args(context.args)
|
|
run(parsed_args)
|
|
context.exit_status = 0
|
|
context.editor = mock_write_in_editor
|
|
expected_config = context.jrnl_config
|
|
expected_config['editor'] = '%s'%editor
|
|
expected_config['journal'] ='features/journals/journal.jrnl'
|
|
|
|
if editor is not None:
|
|
assert mock_write_in_editor.call_count == 1
|
|
assert mock_write_in_editor.call_args[0][0]['editor']==editor
|
|
else:
|
|
# Expect that editor is *never* called
|
|
mock_write_in_editor.assert_not_called()
|
|
except SystemExit as e:
|
|
context.exit_status = e.code
|
|
# fmt: on
|
|
|
|
|
|
@then("the stdin prompt should have been called")
|
|
def override_editor_to_use_stdin(context):
|
|
|
|
try:
|
|
with mock.patch(
|
|
"sys.stdin.read",
|
|
return_value="Zwei peanuts walk into a bar und one of zem was a-salted",
|
|
) as mock_stdin_read, mock.patch(
|
|
"jrnl.install.load_or_install_jrnl", return_value=context.jrnl_config
|
|
), mock.patch(
|
|
"jrnl.Journal.open_journal",
|
|
spec=False,
|
|
return_value="features/journals/journal.jrnl",
|
|
), mock.patch(
|
|
"getpass.getpass", side_effect=_mock_getpass("test")
|
|
):
|
|
parsed_args = parse_args(context.args)
|
|
run(parsed_args)
|
|
context.exit_status = 0
|
|
mock_stdin_read.assert_called_once()
|
|
|
|
except SystemExit as e:
|
|
context.exit_status = e.code
|