mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-19 20:48:31 +02:00
implement behave test steps for format --pretty
This commit is contained in:
parent
1739cee1f0
commit
15efc56779
1 changed files with 15 additions and 7 deletions
|
@ -13,6 +13,7 @@ from behave import given
|
|||
from behave import then
|
||||
import colorama
|
||||
|
||||
|
||||
def style_text(to_bold: bool, text_color: colorama.Fore, text_to_print: str):
|
||||
"""Generate colorized and styled text for expected output. Its purpose is the same as Entry.colorize
|
||||
|
||||
|
@ -27,11 +28,10 @@ def style_text(to_bold: bool, text_color: colorama.Fore, text_to_print: str):
|
|||
"""
|
||||
if to_bold:
|
||||
text_style = Style.BRIGHT
|
||||
else:
|
||||
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
|
||||
|
||||
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")
|
||||
|
@ -39,9 +39,17 @@ 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
|
||||
# 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
Reference in a new issue