Merge branch 'develop' into change-time

This commit is contained in:
Micah Jerome Ellison 2022-05-21 11:39:14 -07:00
commit 1c65ba76df
14 changed files with 111 additions and 45 deletions

View file

@ -9,6 +9,17 @@
- Reformat additional messages and finish centralizing exception handling [\#1424](https://github.com/jrnl-org/jrnl/pull/1424) ([wren](https://github.com/wren)) - Reformat additional messages and finish centralizing exception handling [\#1424](https://github.com/jrnl-org/jrnl/pull/1424) ([wren](https://github.com/wren))
- Reformat messages and add new centralized exception handling [\#1417](https://github.com/jrnl-org/jrnl/pull/1417) ([wren](https://github.com/wren)) - Reformat messages and add new centralized exception handling [\#1417](https://github.com/jrnl-org/jrnl/pull/1417) ([wren](https://github.com/wren))
**Fixed bugs:**
- Empty config file leads to confusing error message [\#1420](https://github.com/jrnl-org/jrnl/issues/1420)
- "Entry not saved" text doesn't appear in default stdin editor [\#1419](https://github.com/jrnl-org/jrnl/issues/1419)
- '-not -contains x' raises an AttributeError exception [\#1350](https://github.com/jrnl-org/jrnl/issues/1350)
- Directory YAML export shows stack trace when it doesn't need to [\#1227](https://github.com/jrnl-org/jrnl/issues/1227)
- The `-not` option with no arguments now outputs error instead of stack trace [\#1466](https://github.com/jrnl-org/jrnl/pull/1466) ([apainintheneck](https://github.com/apainintheneck))
- Give a proper message when trying to use an empty config file [\#1461](https://github.com/jrnl-org/jrnl/pull/1461) ([jonakeys](https://github.com/jonakeys))
- Display "No entry to save, because no text was received" after empty entry on cmdline [\#1459](https://github.com/jrnl-org/jrnl/pull/1459) ([apainintheneck](https://github.com/apainintheneck))
- Yaml export errors now don't show stack trace [\#1449](https://github.com/jrnl-org/jrnl/pull/1449) ([apainintheneck](https://github.com/apainintheneck))
**Deprecated:** **Deprecated:**
- Remove "sample" format and its asteval dependency [\#1435](https://github.com/jrnl-org/jrnl/issues/1435) - Remove "sample" format and its asteval dependency [\#1435](https://github.com/jrnl-org/jrnl/issues/1435)
@ -23,6 +34,9 @@
**Packaging:** **Packaging:**
- Sync jrnl's Python version support more closely to Python release cycle [\#1406](https://github.com/jrnl-org/jrnl/issues/1406) - Sync jrnl's Python version support more closely to Python release cycle [\#1406](https://github.com/jrnl-org/jrnl/issues/1406)
- Bump cryptography from 37.0.1 to 37.0.2 [\#1467](https://github.com/jrnl-org/jrnl/pull/1467) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump cryptography from 36.0.2 to 37.0.1 [\#1462](https://github.com/jrnl-org/jrnl/pull/1462) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump pytest from 7.1.1 to 7.1.2 [\#1458](https://github.com/jrnl-org/jrnl/pull/1458) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump pyproject-flake8 from 0.0.1a3 to 0.0.1a4 [\#1447](https://github.com/jrnl-org/jrnl/pull/1447) ([dependabot[bot]](https://github.com/apps/dependabot)) - Bump pyproject-flake8 from 0.0.1a3 to 0.0.1a4 [\#1447](https://github.com/jrnl-org/jrnl/pull/1447) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump black from 22.1.0 to 22.3.0 [\#1442](https://github.com/jrnl-org/jrnl/pull/1442) ([dependabot[bot]](https://github.com/apps/dependabot)) - Bump black from 22.1.0 to 22.3.0 [\#1442](https://github.com/jrnl-org/jrnl/pull/1442) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump mkdocs from 1.2.3 to 1.3.0 [\#1441](https://github.com/jrnl-org/jrnl/pull/1441) ([dependabot[bot]](https://github.com/apps/dependabot)) - Bump mkdocs from 1.2.3 to 1.3.0 [\#1441](https://github.com/jrnl-org/jrnl/pull/1441) ([dependabot[bot]](https://github.com/apps/dependabot))

View file

@ -243,10 +243,10 @@ def parse_args(args=[]):
reading.add_argument( reading.add_argument(
"-not", "-not",
dest="excluded", dest="excluded",
nargs="?", nargs=1,
default=[], default=[],
metavar="TAG", metavar="TAG",
action="append", action="extend",
help="Exclude entries with this tag", help="Exclude entries with this tag",
) )

View file

@ -75,6 +75,10 @@ def load_or_install_jrnl(alt_config_path):
logging.debug("Reading configuration from file %s", config_path) logging.debug("Reading configuration from file %s", config_path)
config = load_config(config_path) config = load_config(config_path)
if config is None:
print("Unable to parse config file", file=sys.stderr)
sys.exit()
if is_old_version(config_path): if is_old_version(config_path):
from jrnl import upgrade from jrnl import upgrade

View file

@ -135,11 +135,9 @@ def write_mode(args, config, journal, **kwargs):
else: else:
raw = _write_in_editor(config) raw = _write_in_editor(config)
if not raw: if not raw or raw.isspace():
logging.error("Write mode: couldn't get raw text") logging.error("Write mode: couldn't get raw text or entry was empty")
raise JrnlException( raise JrnlException(Message(MsgText.NoTextReceived, MsgType.ERROR))
Message(MsgText.JrnlExceptionMessage.NoTextReceived, MsgType.ERROR)
)
logging.debug( logging.debug(
'Write mode: appending raw text to journal "%s": %s', args.journal_name, raw 'Write mode: appending raw text to journal "%s": %s', args.journal_name, raw

View file

@ -98,7 +98,7 @@ class MsgText(Enum):
""" """
NoTextReceived = """ NoTextReceived = """
Nothing saved to file No entry to save, because no text was received
""" """
# --- Upgrade --- # # --- Upgrade --- #

View file

@ -35,6 +35,8 @@ class TextExporter:
return f"[Journal exported to {path}]" return f"[Journal exported to {path}]"
except IOError as e: except IOError as e:
return f"[{ERROR_COLOR}ERROR{RESET_COLOR}: {e.filename} {e.strerror}]" return f"[{ERROR_COLOR}ERROR{RESET_COLOR}: {e.filename} {e.strerror}]"
except RuntimeError as e:
return e
@classmethod @classmethod
def make_filename(cls, entry): def make_filename(cls, entry):
@ -54,6 +56,8 @@ class TextExporter:
return "[{2}ERROR{3}: {0} {1}]".format( return "[{2}ERROR{3}: {0} {1}]".format(
e.filename, e.strerror, ERROR_COLOR, RESET_COLOR e.filename, e.strerror, ERROR_COLOR, RESET_COLOR
) )
except RuntimeError as e:
return e
return "[Journal exported to {}]".format(path) return "[Journal exported to {}]".format(path)
def _slugify(string): def _slugify(string):

View file

@ -23,12 +23,10 @@ class YAMLExporter(TextExporter):
def export_entry(cls, entry, to_multifile=True): def export_entry(cls, entry, to_multifile=True):
"""Returns a markdown representation of a single entry, with YAML front matter.""" """Returns a markdown representation of a single entry, with YAML front matter."""
if to_multifile is False: if to_multifile is False:
print( raise RuntimeError(
f"{ERROR_COLOR}ERROR{RESET_COLOR}: YAML export must be to individual files. Please \ f"{ERROR_COLOR}ERROR{RESET_COLOR}: YAML export must be to individual files. Please \
specify a directory to export to.", specify a directory to export to."
file=sys.stderr,
) )
return
date_str = entry.date.strftime(entry.journal.config["timeformat"]) date_str = entry.date.strftime(entry.journal.config["timeformat"])
body_wrapper = "\n" if entry.body else "" body_wrapper = "\n" if entry.body else ""
@ -131,10 +129,8 @@ class YAMLExporter(TextExporter):
@classmethod @classmethod
def export_journal(cls, journal): def export_journal(cls, journal):
"""Returns an error, as YAML export requires a directory as a target.""" """Returns an error, as YAML export requires a directory as a target."""
print( raise RuntimeError(
"{}ERROR{}: YAML export must be to individual files. Please specify a directory to export to.".format( "{}ERROR{}: YAML export must be to individual files. Please specify a directory to export to.".format(
ERROR_COLOR, RESET_COLOR ERROR_COLOR, RESET_COLOR
), )
file=sys.stderr,
) )
return

52
poetry.lock generated
View file

@ -137,7 +137,7 @@ test = ["flake8 (==3.7.8)", "hypothesis (==3.55.3)"]
[[package]] [[package]]
name = "cryptography" name = "cryptography"
version = "36.0.2" version = "37.0.2"
description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers."
category = "main" category = "main"
optional = false optional = false
@ -152,7 +152,7 @@ docstest = ["pyenchant (>=1.6.11)", "twine (>=1.12.0)", "sphinxcontrib-spelling
pep8test = ["black", "flake8", "flake8-import-order", "pep8-naming"] pep8test = ["black", "flake8", "flake8-import-order", "pep8-naming"]
sdist = ["setuptools_rust (>=0.11.4)"] sdist = ["setuptools_rust (>=0.11.4)"]
ssh = ["bcrypt (>=3.1.5)"] ssh = ["bcrypt (>=3.1.5)"]
test = ["pytest (>=6.2.0)", "pytest-cov", "pytest-subtests", "pytest-xdist", "pretend", "iso8601", "pytz", "hypothesis (>=1.11.4,!=3.79.2)"] test = ["pytest (>=6.2.0)", "pytest-benchmark", "pytest-cov", "pytest-subtests", "pytest-xdist", "pretend", "iso8601", "pytz", "hypothesis (>=1.11.4,!=3.79.2)"]
[[package]] [[package]]
name = "decorator" name = "decorator"
@ -641,7 +641,7 @@ tomli = {version = "*", markers = "python_version < \"3.11\""}
[[package]] [[package]]
name = "pytest" name = "pytest"
version = "7.1.1" version = "7.1.2"
description = "pytest: simple powerful testing with Python" description = "pytest: simple powerful testing with Python"
category = "main" category = "main"
optional = false optional = false
@ -1054,26 +1054,28 @@ commonmark = [
{file = "commonmark-0.9.1.tar.gz", hash = "sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60"}, {file = "commonmark-0.9.1.tar.gz", hash = "sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60"},
] ]
cryptography = [ cryptography = [
{file = "cryptography-36.0.2-cp36-abi3-macosx_10_10_universal2.whl", hash = "sha256:4e2dddd38a5ba733be6a025a1475a9f45e4e41139d1321f412c6b360b19070b6"}, {file = "cryptography-37.0.2-cp36-abi3-macosx_10_10_universal2.whl", hash = "sha256:ef15c2df7656763b4ff20a9bc4381d8352e6640cfeb95c2972c38ef508e75181"},
{file = "cryptography-36.0.2-cp36-abi3-macosx_10_10_x86_64.whl", hash = "sha256:4881d09298cd0b669bb15b9cfe6166f16fc1277b4ed0d04a22f3d6430cb30f1d"}, {file = "cryptography-37.0.2-cp36-abi3-macosx_10_10_x86_64.whl", hash = "sha256:3c81599befb4d4f3d7648ed3217e00d21a9341a9a688ecdd615ff72ffbed7336"},
{file = "cryptography-36.0.2-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:ea634401ca02367c1567f012317502ef3437522e2fc44a3ea1844de028fa4b84"}, {file = "cryptography-37.0.2-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:2bd1096476aaac820426239ab534b636c77d71af66c547b9ddcd76eb9c79e004"},
{file = "cryptography-36.0.2-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl", hash = "sha256:7be666cc4599b415f320839e36367b273db8501127b38316f3b9f22f17a0b815"}, {file = "cryptography-37.0.2-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl", hash = "sha256:31fe38d14d2e5f787e0aecef831457da6cec68e0bb09a35835b0b44ae8b988fe"},
{file = "cryptography-36.0.2-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8241cac0aae90b82d6b5c443b853723bcc66963970c67e56e71a2609dc4b5eaf"}, {file = "cryptography-37.0.2-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:093cb351031656d3ee2f4fa1be579a8c69c754cf874206be1d4cf3b542042804"},
{file = "cryptography-36.0.2-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7b2d54e787a884ffc6e187262823b6feb06c338084bbe80d45166a1cb1c6c5bf"}, {file = "cryptography-37.0.2-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:59b281eab51e1b6b6afa525af2bd93c16d49358404f814fe2c2410058623928c"},
{file = "cryptography-36.0.2-cp36-abi3-manylinux_2_24_x86_64.whl", hash = "sha256:c2c5250ff0d36fd58550252f54915776940e4e866f38f3a7866d92b32a654b86"}, {file = "cryptography-37.0.2-cp36-abi3-manylinux_2_24_x86_64.whl", hash = "sha256:0cc20f655157d4cfc7bada909dc5cc228211b075ba8407c46467f63597c78178"},
{file = "cryptography-36.0.2-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:ec6597aa85ce03f3e507566b8bcdf9da2227ec86c4266bd5e6ab4d9e0cc8dab2"}, {file = "cryptography-37.0.2-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:f8ec91983e638a9bcd75b39f1396e5c0dc2330cbd9ce4accefe68717e6779e0a"},
{file = "cryptography-36.0.2-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:ca9f686517ec2c4a4ce930207f75c00bf03d94e5063cbc00a1dc42531511b7eb"}, {file = "cryptography-37.0.2-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:46f4c544f6557a2fefa7ac8ac7d1b17bf9b647bd20b16decc8fbcab7117fbc15"},
{file = "cryptography-36.0.2-cp36-abi3-win32.whl", hash = "sha256:f64b232348ee82f13aac22856515ce0195837f6968aeaa94a3d0353ea2ec06a6"}, {file = "cryptography-37.0.2-cp36-abi3-win32.whl", hash = "sha256:731c8abd27693323b348518ed0e0705713a36d79fdbd969ad968fbef0979a7e0"},
{file = "cryptography-36.0.2-cp36-abi3-win_amd64.whl", hash = "sha256:53e0285b49fd0ab6e604f4c5d9c5ddd98de77018542e88366923f152dbeb3c29"}, {file = "cryptography-37.0.2-cp36-abi3-win_amd64.whl", hash = "sha256:471e0d70201c069f74c837983189949aa0d24bb2d751b57e26e3761f2f782b8d"},
{file = "cryptography-36.0.2-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:32db5cc49c73f39aac27574522cecd0a4bb7384e71198bc65a0d23f901e89bb7"}, {file = "cryptography-37.0.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a68254dd88021f24a68b613d8c51d5c5e74d735878b9e32cc0adf19d1f10aaf9"},
{file = "cryptography-36.0.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b3d199647468d410994dbeb8cec5816fb74feb9368aedf300af709ef507e3e"}, {file = "cryptography-37.0.2-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:a7d5137e556cc0ea418dca6186deabe9129cee318618eb1ffecbd35bee55ddc1"},
{file = "cryptography-36.0.2-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:da73d095f8590ad437cd5e9faf6628a218aa7c387e1fdf67b888b47ba56a17f0"}, {file = "cryptography-37.0.2-pp38-pypy38_pp73-macosx_10_10_x86_64.whl", hash = "sha256:aeaba7b5e756ea52c8861c133c596afe93dd716cbcacae23b80bc238202dc023"},
{file = "cryptography-36.0.2-pp38-pypy38_pp73-macosx_10_10_x86_64.whl", hash = "sha256:0a3bf09bb0b7a2c93ce7b98cb107e9170a90c51a0162a20af1c61c765b90e60b"}, {file = "cryptography-37.0.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95e590dd70642eb2079d280420a888190aa040ad20f19ec8c6e097e38aa29e06"},
{file = "cryptography-36.0.2-pp38-pypy38_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:8897b7b7ec077c819187a123174b645eb680c13df68354ed99f9b40a50898f77"}, {file = "cryptography-37.0.2-pp38-pypy38_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:1b9362d34363f2c71b7853f6251219298124aa4cc2075ae2932e64c91a3e2717"},
{file = "cryptography-36.0.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:82740818f2f240a5da8dfb8943b360e4f24022b093207160c77cadade47d7c85"}, {file = "cryptography-37.0.2-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:e53258e69874a306fcecb88b7534d61820db8a98655662a3dd2ec7f1afd9132f"},
{file = "cryptography-36.0.2-pp38-pypy38_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:1f64a62b3b75e4005df19d3b5235abd43fa6358d5516cfc43d87aeba8d08dd51"}, {file = "cryptography-37.0.2-pp39-pypy39_pp73-macosx_10_10_x86_64.whl", hash = "sha256:1f3bfbd611db5cb58ca82f3deb35e83af34bb8cf06043fa61500157d50a70982"},
{file = "cryptography-36.0.2-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:e167b6b710c7f7bc54e67ef593f8731e1f45aa35f8a8a7b72d6e42ec76afd4b3"}, {file = "cryptography-37.0.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:419c57d7b63f5ec38b1199a9521d77d7d1754eb97827bbb773162073ccd8c8d4"},
{file = "cryptography-36.0.2.tar.gz", hash = "sha256:70f8f4f7bb2ac9f340655cbac89d68c527af5bb4387522a8413e841e3e6628c9"}, {file = "cryptography-37.0.2-pp39-pypy39_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:dc26bb134452081859aa21d4990474ddb7e863aa39e60d1592800a8865a702de"},
{file = "cryptography-37.0.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:3b8398b3d0efc420e777c40c16764d6870bcef2eb383df9c6dbb9ffe12c64452"},
{file = "cryptography-37.0.2.tar.gz", hash = "sha256:f224ad253cc9cea7568f49077007d2263efa57396a2f2f78114066fd54b5c68e"},
] ]
decorator = [ decorator = [
{file = "decorator-5.1.1-py3-none-any.whl", hash = "sha256:b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186"}, {file = "decorator-5.1.1-py3-none-any.whl", hash = "sha256:b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186"},
@ -1279,8 +1281,8 @@ pyproject-flake8 = [
{file = "pyproject_flake8-0.0.1a4-py2.py3-none-any.whl", hash = "sha256:1a8f94e18d08677ee780625049d9d00a9ee823661c6606caab8a383351037a75"}, {file = "pyproject_flake8-0.0.1a4-py2.py3-none-any.whl", hash = "sha256:1a8f94e18d08677ee780625049d9d00a9ee823661c6606caab8a383351037a75"},
] ]
pytest = [ pytest = [
{file = "pytest-7.1.1-py3-none-any.whl", hash = "sha256:92f723789a8fdd7180b6b06483874feca4c48a5c76968e03bb3e7f806a1869ea"}, {file = "pytest-7.1.2-py3-none-any.whl", hash = "sha256:13d0e3ccfc2b6e26be000cb6568c832ba67ba32e719443bfe725814d3c42433c"},
{file = "pytest-7.1.1.tar.gz", hash = "sha256:841132caef6b1ad17a9afde46dc4f6cfa59a05f9555aae5151f73bdf2820ca63"}, {file = "pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"},
] ]
pytest-bdd = [ pytest-bdd = [
{file = "pytest-bdd-5.0.0.tar.gz", hash = "sha256:fab7093ed3d5e51ee0c68de093c90e4f40de345bd9a54a188b2991ce2a2a39cf"}, {file = "pytest-bdd-5.0.0.tar.gz", hash = "sha256:fab7093ed3d5e51ee0c68de093c90e4f40de345bd9a54a188b2991ce2a2a39cf"},

View file

@ -85,7 +85,6 @@ Feature: Multiple journals
Then the output should contain "Journal encrypted to features/journals/basic_onefile.journal" Then the output should contain "Journal encrypted to features/journals/basic_onefile.journal"
And the config should contain "encrypt: false" And the config should contain "encrypt: false"
Scenario: Don't overwrite main config when decrypting a journal in an alternate config Scenario: Don't overwrite main config when decrypting a journal in an alternate config
Given the config "editor_encrypted.yaml" exists Given the config "editor_encrypted.yaml" exists
And we use the password "bad doggie no biscuit" if prompted And we use the password "bad doggie no biscuit" if prompted
@ -93,3 +92,14 @@ Feature: Multiple journals
When we run "jrnl --cf editor_encrypted.yaml --decrypt" When we run "jrnl --cf editor_encrypted.yaml --decrypt"
Then the config should contain "encrypt: true" Then the config should contain "encrypt: true"
And the output should not contain "Wrong password" And the output should not contain "Wrong password"
Scenario: Show an error message when the config file is empty
Given we use the config "empty_file.yaml"
When we run "jrnl -1"
Then the error output should contain "Unable to parse config file"
Scenario: Show an error message when using --config-file with empty file
Given the config "empty_file.yaml" exists
And we use the config "basic_onefile.yaml"
When we run "jrnl --cf empty_file.yaml"
Then the error output should contain "Unable to parse config file"

View file

@ -425,6 +425,20 @@ Feature: Custom formats
| basic_folder.yaml | | basic_folder.yaml |
# | basic_dayone.yaml | # | basic_dayone.yaml |
Scenario Outline: Exporting YAML to nonexistent directory leads to user-friendly error with no traceback
Given we use the config "<config_file>"
And we use the password "test" if prompted
When we run "jrnl --export yaml --file nonexistent_dir"
Then the output should contain "YAML export must be to individual files"
And the output should not contain "Traceback"
Examples: configs
| config_file |
| basic_onefile.yaml |
| basic_encrypted.yaml |
| basic_folder.yaml |
| basic_dayone.yaml |
@skip_win # @todo YAML exporter does not correctly export emoji on Windows @skip_win # @todo YAML exporter does not correctly export emoji on Windows
Scenario Outline: Add a blank line to YAML export if there isn't one already Scenario Outline: Add a blank line to YAML export if there isn't one already
# https://github.com/jrnl-org/jrnl/issues/768 # https://github.com/jrnl-org/jrnl/issues/768

View file

@ -73,12 +73,12 @@ Feature: Writing new entries.
| basic_dayone.yaml | | basic_dayone.yaml |
| basic_folder.yaml | | basic_folder.yaml |
Scenario Outline: Writing an empty entry from the editor should yield "Nothing saved to file" message Scenario Outline: Writing an empty entry from the editor should yield "No entry to save" message
Given we use the config "<config_file>" Given we use the config "<config_file>"
And we write nothing to the editor if opened And we write nothing to the editor if opened
And we use the password "test" if prompted And we use the password "test" if prompted
When we run "jrnl --edit" When we run "jrnl --edit"
Then the error output should contain "Nothing saved to file" Then the error output should contain "No entry to save, because no text was received"
And the editor should have been called And the editor should have been called
Examples: configs Examples: configs
@ -89,6 +89,20 @@ Feature: Writing new entries.
| basic_encrypted.yaml | | basic_encrypted.yaml |
| basic_onefile.yaml | | basic_onefile.yaml |
Scenario Outline: Writing an empty entry from the command line should yield "No entry to save" message
Given we use the config "<config_file>"
And we use the password "test" if prompted
When we run "jrnl" and enter "\x04"
Then the error output should contain "No entry to save, because no text was received"
When we run "jrnl" and enter " \t \n \x04"
Then the error output should contain "No entry to save, because no text was received"
Examples: configs
| config_file |
| basic_onefile.yaml |
| basic_encrypted.yaml |
| basic_folder.yaml |
| basic_dayone.yaml |
Scenario Outline: Writing an empty entry from the command line with no editor should yield nothing Scenario Outline: Writing an empty entry from the command line with no editor should yield nothing
Given we use the config "<config_file>" Given we use the config "<config_file>"

View file

View file

@ -101,7 +101,11 @@ def we_use_the_config(request, temp_dir, working_dir):
# @todo get rid of this by using default config values # @todo get rid of this by using default config values
# merge in version number # merge in version number
if config_file.endswith("yaml") and os.path.exists(config_dest): if (
config_file.endswith("yaml")
and os.path.exists(config_dest)
and os.path.getsize(config_dest) > 0
):
# Add jrnl version to file for 2.x journals # Add jrnl version to file for 2.x journals
with open(config_dest, "a") as cf: with open(config_dest, "a") as cf:
cf.write("version: {}".format(__version__)) cf.write("version: {}".format(__version__))

View file

@ -96,6 +96,12 @@ def test_end_date_alone():
assert expected == cli_as_dict("-to 2020-01-01") assert expected == cli_as_dict("-to 2020-01-01")
def test_not_empty():
with pytest.raises(SystemExit) as wrapped_e:
cli_as_dict("-not")
assert wrapped_e.value.code == 2
def test_not_alone(): def test_not_alone():
assert cli_as_dict("-not test") == expected_args(excluded=["test"]) assert cli_as_dict("-not test") == expected_args(excluded=["test"])