Tests for parsing DayOne entries without Timezone

This commit is contained in:
Manuel Ebert 2013-08-17 13:19:54 -07:00
parent 552d2a00ff
commit 2a981d51e2
3 changed files with 22 additions and 7 deletions

View file

@ -1,8 +1,10 @@
from behave import *
from jrnl import jrnl, Journal
from jrnl import jrnl, Journal, util
from dateutil import parser as date_parser
import os
import sys
import json
import pytz
try:
from io import StringIO
except ImportError:
@ -73,7 +75,7 @@ def check_output_json(context):
def check_output_field(context, field, number=1):
out = context.stdout_capture.getvalue()
out_json = json.loads(out)
assert field in out_json [field, out_json]
assert field in out_json, [field, out_json]
assert len(out_json[field]) == number, len(out_json[field])
@then('"{field}" in the json output should not contain "{key}"')
@ -97,6 +99,15 @@ def check_output(context):
for line_text, line_out in zip(text, out):
assert line_text.strip() == line_out.strip(), [line_text.strip(), line_out.strip()]
@then('the output should contain "{text}" in the local time')
def check_output_time_inline(context, text):
out = context.stdout_capture.getvalue()
local_tz = pytz.timezone(util.get_local_timezone())
utc_time = date_parser.parse(text)
date = utc_time + local_tz._utcoffset
local_date = date.strftime("%Y-%m-%d %H:%M")
assert local_date in out, local_date
@then('the output should contain "{text}"')
def check_output_inline(context, text):
out = context.stdout_capture.getvalue()