mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-28 21:46:13 +02:00
Fix issue #662 to properly handle day names as new entry dates and
command line (-on, -from, -to).
This commit is contained in:
parent
9588913100
commit
47e10fbee7
4 changed files with 67 additions and 8 deletions
|
@ -62,3 +62,50 @@ Feature: Zapped bugs should stay dead.
|
|||
Then the output should contain "I'm going to activate the machine."
|
||||
Then the output should contain "I've crossed so many timelines. Is there any going back?"
|
||||
|
||||
Scenario: Create entry using day of the week as entry date.
|
||||
Given we use the config "basic.yaml"
|
||||
When we run "jrnl monday: This is an entry on a Monday."
|
||||
Then we should see the message "Entry added"
|
||||
When we run "jrnl -1"
|
||||
Then the output should contain "monday at 9am" in the local time
|
||||
Then the output should contain "This is an entry on a Monday."
|
||||
|
||||
Scenario: Create entry using day of the week abbreviations as entry date.
|
||||
Given we use the config "basic.yaml"
|
||||
When we run "jrnl fri: This is an entry on a Friday."
|
||||
Then we should see the message "Entry added"
|
||||
When we run "jrnl -1"
|
||||
Then the output should contain "friday at 9am" in the local time
|
||||
|
||||
Scenario: Displaying entries using -on today should display entries created today.
|
||||
Given we use the config "basic.yaml"
|
||||
When we run "jrnl today: Adding an entry right now."
|
||||
Then we should see the message "Entry added"
|
||||
When we run "jrnl -on today"
|
||||
Then the output should contain "Adding an entry right now."
|
||||
|
||||
Scenario: Displaying entries using -from day should display correct entries
|
||||
Given we use the config "basic.yaml"
|
||||
When we run "jrnl yesterday: This thing happened yesterday"
|
||||
Then we should see the message "Entry added"
|
||||
When we run "jrnl today at 11:59pm: Adding an entry right now."
|
||||
Then we should see the message "Entry added"
|
||||
When we run "jrnl tomorrow: A future entry."
|
||||
Then we should see the message "Entry added"
|
||||
When we run "jrnl -from today"
|
||||
Then the output should contain "Adding an entry right now."
|
||||
Then the output should contain "A future entry."
|
||||
Then the output should not contain "This thing happened yesterday"
|
||||
|
||||
Scenario: Displaying entries using -from and -to day should display correct entries
|
||||
Given we use the config "basic.yaml"
|
||||
When we run "jrnl yesterday: This thing happened yesterday"
|
||||
Then we should see the message "Entry added"
|
||||
When we run "jrnl today at 11:59pm: Adding an entry right now."
|
||||
Then we should see the message "Entry added"
|
||||
When we run "jrnl tomorrow: A future entry."
|
||||
Then we should see the message "Entry added"
|
||||
When we run "jrnl -from yesterday -to today"
|
||||
Then the output should contain "This thing happened yesterday"
|
||||
Then the output should contain "Adding an entry right now."
|
||||
Then the output should not contain "A future entry."
|
||||
|
|
|
@ -6,11 +6,18 @@ from jrnl import cli, install, Journal, util, plugins
|
|||
from jrnl import __version__
|
||||
from dateutil import parser as date_parser
|
||||
from collections import defaultdict
|
||||
try: import parsedatetime.parsedatetime_consts as pdt
|
||||
except ImportError: import parsedatetime as pdt
|
||||
import time
|
||||
import os
|
||||
import json
|
||||
import yaml
|
||||
import keyring
|
||||
|
||||
consts = pdt.Constants(usePyICU=False)
|
||||
consts.DOWParseStyle = -1 # Prefers past weekdays
|
||||
CALENDAR = pdt.Calendar(consts)
|
||||
|
||||
|
||||
class TestKeyring(keyring.backend.KeyringBackend):
|
||||
"""A test keyring that just stores its valies in a hash"""
|
||||
|
@ -180,9 +187,9 @@ def check_output(context, text=None):
|
|||
def check_output_time_inline(context, text):
|
||||
out = context.stdout_capture.getvalue()
|
||||
local_tz = tzlocal.get_localzone()
|
||||
utc_time = date_parser.parse(text)
|
||||
local_date = utc_time.astimezone(local_tz).strftime("%Y-%m-%d %H:%M")
|
||||
assert local_date in out, local_date
|
||||
date, flag = CALENDAR.parse(text)
|
||||
output_date = time.strftime("%Y-%m-%d %H:%M",date)
|
||||
assert output_date in out, output_date
|
||||
|
||||
|
||||
@then('the output should contain')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue