mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 21:18:32 +02:00
Add tests.
This commit is contained in:
parent
7d0b4b6b19
commit
5f47a60338
6 changed files with 64 additions and 5 deletions
19
features/data/configs/format_md.yaml
Normal file
19
features/data/configs/format_md.yaml
Normal file
|
@ -0,0 +1,19 @@
|
|||
colors:
|
||||
body: none
|
||||
date: none
|
||||
tags: none
|
||||
title: none
|
||||
default_hour: 9
|
||||
default_minute: 0
|
||||
display_format: markdown
|
||||
editor: ''
|
||||
encrypt: false
|
||||
highlight: true
|
||||
indent_character: '|'
|
||||
journals:
|
||||
default: features/journals/simple.journal
|
||||
linewrap: 80
|
||||
tagsymbols: '@'
|
||||
template: false
|
||||
timeformat: '%Y-%m-%d %H:%M'
|
||||
version: v2.4.5
|
19
features/data/configs/format_text.yaml
Normal file
19
features/data/configs/format_text.yaml
Normal file
|
@ -0,0 +1,19 @@
|
|||
colors:
|
||||
body: none
|
||||
date: none
|
||||
tags: none
|
||||
title: none
|
||||
default_hour: 9
|
||||
default_minute: 0
|
||||
display_format: text
|
||||
editor: ''
|
||||
encrypt: false
|
||||
highlight: true
|
||||
indent_character: '|'
|
||||
journals:
|
||||
default: features/journals/simple.journal
|
||||
linewrap: 80
|
||||
tagsymbols: '@'
|
||||
template: false
|
||||
timeformat: '%Y-%m-%d %H:%M'
|
||||
version: v2.4.5
|
|
@ -512,3 +512,23 @@ Feature: Custom formats
|
|||
| basic_encrypted |
|
||||
| basic_folder |
|
||||
| basic_dayone |
|
||||
|
||||
Scenario: Markdown Support from config file
|
||||
Given we use the config "format_md.yaml"
|
||||
When we run "jrnl -n 1"
|
||||
Then the output should be
|
||||
"""
|
||||
# 2013
|
||||
## June
|
||||
### 2013-06-10 15:40 Life is good.
|
||||
But I'm better.
|
||||
"""
|
||||
|
||||
Scenario: Text Formatter from config file
|
||||
Given we use the config "format_text.yaml"
|
||||
When we run "jrnl -n 1"
|
||||
Then the output should be
|
||||
"""
|
||||
[2013-06-10 15:40] Life is good.
|
||||
But I'm better.
|
||||
"""
|
||||
|
|
|
@ -35,7 +35,6 @@ class Journal:
|
|||
"highlight": True,
|
||||
"linewrap": 80,
|
||||
"indent_character": "|",
|
||||
"display_format": "text",
|
||||
}
|
||||
self.config.update(kwargs)
|
||||
# Set up date parser
|
||||
|
|
|
@ -49,7 +49,6 @@ default_config = {
|
|||
"linewrap": 79,
|
||||
"indent_character": "|",
|
||||
"colors": {"date": "none", "title": "none", "body": "none", "tags": "none",},
|
||||
"display_format": "text",
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ def _delete_search_results(journal, old_entries, **kwargs):
|
|||
journal.write()
|
||||
|
||||
|
||||
def _display_search_results(args, journal, config, **kwargs):
|
||||
def _display_search_results(args, journal, **kwargs):
|
||||
if args.short:
|
||||
print(journal.pprint(short=True))
|
||||
|
||||
|
@ -302,6 +302,9 @@ def _display_search_results(args, journal, config, **kwargs):
|
|||
print(exporter.export(journal, args.filename))
|
||||
else:
|
||||
# Display according display_format config option
|
||||
config_selected = config.get("display_format", journal.config["display_format"])
|
||||
config_selected = kwargs['config'].get("display_format")
|
||||
exporter = plugins.get_exporter(config_selected)
|
||||
if config_selected:
|
||||
print(exporter.export(journal, args.filename))
|
||||
else:
|
||||
print(journal.pprint())
|
||||
|
|
Loading…
Add table
Reference in a new issue