implement behave test steps for format --pretty

This commit is contained in:
Suhas 2021-02-04 08:51:33 -05:00
parent 1739cee1f0
commit 15efc56779

View file

@ -13,6 +13,7 @@ from behave import given
from behave import then from behave import then
import colorama import colorama
def style_text(to_bold: bool, text_color: colorama.Fore, text_to_print: str): 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 """Generate colorized and styled text for expected output. Its purpose is the same as Entry.colorize
@ -33,14 +34,21 @@ def style_text(to_bold: bool, text_color: colorama.Fore, text_to_print: str):
return text_style + text_color + text_to_print + Style.RESET_ALL return text_style + text_color + text_to_print + Style.RESET_ALL
@then("the output should be pretty printed") @then("the output should be pretty printed")
def check_export_pretty(context): def check_export_pretty(context):
out = context.stdout_capture.getvalue() out = context.stdout_capture.getvalue()
lines = out.splitlines() lines = out.splitlines()
# As per the configuration, # 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.') 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 assert lines[0] == expected_colorized_title