mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-11 17:46:12 +02:00
Address code review
make the test perform actual qualification
make format
update other test as well
remove unnecessary mock
reset .gitignore to e6c0a16342
delete pretty.yaml
remove launch.json
reorder mocks
convert scenario to scenario outline for behavioral coverage
fix scenario syntax
comment out problematic step; add password handling
reorder import
meld conditional code
rework melded export logic
update code to be exercised in test
This commit is contained in:
parent
edc8cd93e3
commit
0a6e5f94c0
8 changed files with 44 additions and 127 deletions
|
@ -1,19 +0,0 @@
|
|||
default_hour: 9
|
||||
default_minute: 0
|
||||
editor: "vim"
|
||||
encrypt: false
|
||||
highlight: true
|
||||
journals:
|
||||
default: features/journals/simple.journal
|
||||
linewrap: 80
|
||||
tagsymbols: "@"
|
||||
template: false
|
||||
timeformat: "%Y-%m-%d %H:%M"
|
||||
indent_character: "|"
|
||||
colors:
|
||||
body: green
|
||||
title: blue
|
||||
date: red
|
||||
tags: magenta
|
||||
|
||||
|
|
@ -1,16 +1,30 @@
|
|||
Feature: Custom formats
|
||||
|
||||
Scenario: Short printing via --format flag
|
||||
Given We use the config "pretty.yaml"
|
||||
Scenario Outline: Short printing via --format flag
|
||||
Given We use the config "<config>.yaml"
|
||||
And we use the password "test" if prompted
|
||||
When we run "jrnl --format short -3"
|
||||
Then we should get no error
|
||||
And the output should be pretty printed
|
||||
|
||||
Scenario: Pretty Printing aka the Default
|
||||
Given We use the config "pretty.yaml"
|
||||
|
||||
Examples: configs
|
||||
| config |
|
||||
| basic_onefile |
|
||||
| basic_encrypted |
|
||||
| basic_folder |
|
||||
| basic_dayone |
|
||||
|
||||
Scenario Outline: Pretty Printing aka the Default
|
||||
Given We use the config "<config>.yaml"
|
||||
And we use the password "test" if prompted
|
||||
When we run "jrnl --format pretty -3"
|
||||
Then we should get no error
|
||||
And the output should be pretty printed
|
||||
|
||||
Examples: configs
|
||||
| config |
|
||||
| basic_onefile |
|
||||
| basic_encrypted |
|
||||
| basic_folder |
|
||||
| basic_dayone |
|
||||
|
||||
Scenario Outline: JSON format
|
||||
Given we use the config "<config>.yaml"
|
||||
|
|
|
@ -430,7 +430,6 @@ def run(context, command, text=""):
|
|||
patch("sys.stdin.read", side_effect=lambda: text), \
|
||||
patch("jrnl.time.parse", side_effect=_mock_time_parse(context)), \
|
||||
patch("jrnl.config.get_config_path", side_effect=lambda: context.config_path), \
|
||||
patch("jrnl.install.load_or_install_jrnl",wraps=jrnl.install.load_or_install_jrnl), \
|
||||
patch("jrnl.install.get_config_path", side_effect=lambda: context.config_path) \
|
||||
:
|
||||
context.editor = mock_editor
|
||||
|
|
|
@ -8,48 +8,8 @@ import shutil
|
|||
import random
|
||||
import string
|
||||
from xml.etree import ElementTree
|
||||
from colorama import Fore, Style
|
||||
from behave import given
|
||||
from behave import then
|
||||
import colorama
|
||||
|
||||
|
||||
def style_text(to_bold: bool, text_color: Fore, text_to_print: str):
|
||||
"""Generate colorized and styled text for expected output. Its purpose is the same as Entry.colorize
|
||||
|
||||
:param to_bold: Flag whether the text should be bolded
|
||||
:type to_bold: bool
|
||||
:param text_color: Valid colorama.Fore color for the text
|
||||
:type text_color: colorama.Fore
|
||||
:param text_to_print: Message contents
|
||||
:type text_to_print: str
|
||||
:return: Styled and colored output
|
||||
:rtype: str
|
||||
"""
|
||||
if to_bold:
|
||||
text_style = Style.BRIGHT
|
||||
else:
|
||||
text_style = Style.NORMAL
|
||||
text_color = getattr(colorama.Fore, text_color.upper(), None)
|
||||
return text_style + text_color + text_to_print + Style.RESET_ALL
|
||||
|
||||
|
||||
@then("the output should be pretty printed")
|
||||
def check_export_pretty(context):
|
||||
out = context.stdout_capture.getvalue()
|
||||
lines = out.splitlines()
|
||||
|
||||
# As per the configuration,
|
||||
expected_colorized_title = (
|
||||
style_text(
|
||||
True, context.jrnl_config["colors"]["date"].upper(), "2013-06-09 15:39"
|
||||
)
|
||||
+ " "
|
||||
+ style_text(
|
||||
True, context.jrnl_config["colors"]["title"].upper(), "My first entry."
|
||||
)
|
||||
)
|
||||
assert lines[0] == expected_colorized_title
|
||||
|
||||
|
||||
@then("the output should be parsable as json")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue