Add calendar export test scaffolding

This commit is contained in:
Aaron Lichtman 2023-07-03 04:41:51 -07:00
parent 0a2f040a9e
commit 1fa091d7dc
No known key found for this signature in database
GPG key ID: D046D019DC745EDA
2 changed files with 20 additions and 1 deletions

View file

@ -39,6 +39,7 @@ class CalendarHeatmapExporter(TextExporter):
curr_year = datetime.now().year curr_year = datetime.now().year
curr_month = datetime.now().month curr_month = datetime.now().month
curr_day = datetime.now().day curr_day = datetime.now().day
hit_first_entry = False
with console.capture() as capture: with console.capture() as capture:
for year, month_journaling_freq in journal_frequency.items(): for year, month_journaling_freq in journal_frequency.items():
year_calendar = [] year_calendar = []
@ -47,7 +48,12 @@ class CalendarHeatmapExporter(TextExporter):
break break
entries_this_month = sum(month_journaling_freq[month].values()) entries_this_month = sum(month_journaling_freq[month].values())
if entries_this_month == 0: if not hit_first_entry and entries_this_month > 0:
hit_first_entry = True
if entries_this_month == 0 and not hit_first_entry:
continue
elif entries_this_month == 0:
entry_msg = "No entries" entry_msg = "No entries"
elif entries_this_month == 1: elif entries_this_month == 1:
entry_msg = "1 entry" entry_msg = "1 entry"

View file

@ -565,6 +565,19 @@ Feature: Custom formats
| basic_dayone.yaml | | basic_dayone.yaml |
Scenario Outline: Export calendar heatmap
Given we use the config "<config_file>"
And we use the password "test" if prompted
When we run "jrnl --format calendar"
Then the output should be
2013-06-09, 1
2013-06-10, 1
Examples: configs
| config_file |
| simple.yaml |
Scenario Outline: display_format short and pretty do not crash if specified as config values Scenario Outline: display_format short and pretty do not crash if specified as config values
Given we use the config "<config_file>" Given we use the config "<config_file>"
And we use the password "test" if prompted And we use the password "test" if prompted