Skip to content

Commit ee285e8

Browse files
committed
trying to reproduce #836
1 parent 3a4298b commit ee285e8

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

tests/cli_test.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,3 +1018,71 @@ def test_list_now(runner, tmpdir):
10181018

10191019
result = runner.invoke(main_khal, ['list', 'now'])
10201020
assert not result.exception
1021+
1022+
1023+
@freeze_time('2019-01-22 06:30:00', tz_offset=0)
1024+
def test_reproduce_836(runner, tmpdir):
1025+
# while it is already 2019-01-22 in UTC, it is still 2019-01-21 in
1026+
# America/Los_Angeles
1027+
import datetime as dt
1028+
print(dt.datetime.now())
1029+
import pytz
1030+
local_tz = pytz.timezone('America/Los_Angeles')
1031+
print(dt.datetime.now(local_tz))
1032+
runner = runner()
1033+
1034+
1035+
xdg_config_home = tmpdir.join('.config')
1036+
config_file = xdg_config_home.join('khal').join('config')
1037+
config_file.write("""
1038+
[calendars]
1039+
[[one]]
1040+
path = {}
1041+
color = dark blue
1042+
[[two]]
1043+
path = {}
1044+
color = dark green
1045+
[[three]]
1046+
path = {}
1047+
[locale]
1048+
dateformat = %Y-%m-%d
1049+
longdateformat = %Y-%m-%d
1050+
datetimeformat = %Y-%m-%d %H:%M
1051+
longdatetimeformat = %Y-%m-%d %H:%M
1052+
timeformat = %H:%M
1053+
default_timezone = America/Los_Angeles
1054+
local_timezone = America/Los_Angeles
1055+
""".format(
1056+
tmpdir.join('calendar'),
1057+
tmpdir.join('calendar2'),
1058+
tmpdir.join('calendar3'),
1059+
))
1060+
1061+
print(runner.invoke(main_khal, 'printformats --now'.split()).output)
1062+
1063+
result = runner.invoke(main_khal, 'new -a one 2019-01-20 23:00 24:00 Meeting on 20st at 23:00'.split())
1064+
result = runner.invoke(main_khal, 'new -a one 2019-01-21 23:00 24:00 Meeting on 21st at 23:00'.split())
1065+
result = runner.invoke(main_khal, 'new -a one 2019-01-22 17:00 20:00 Meeting on 22nd at 17:00'.split())
1066+
result = runner.invoke(main_khal, 'new -a one 23:00 Meeting today at 23:00'.split())
1067+
1068+
print('$ khal calendar 2019-01-20')
1069+
result = runner.invoke(main_khal, ['list', '2019-01-20'])
1070+
print(result.output)
1071+
assert result.output.startswith('Sunday, 2019-01-20')
1072+
1073+
print('$ khal calendar 2019-01-21')
1074+
result = runner.invoke(main_khal, ['list', '2019-01-21'])
1075+
print(result.output)
1076+
assert result.output.startswith('Today, 2019-01-21')
1077+
1078+
print('$ khal calendar 2019-01-22')
1079+
result = runner.invoke(main_khal, ['list', '2019-01-22'])
1080+
print(result.output)
1081+
assert result.output.startswith('Tomorrow, 2019-01-22')
1082+
1083+
# this part tests, if the default start (today) is also correctly set to the
1084+
# 21st
1085+
print('$ khal calendar')
1086+
result = runner.invoke(main_khal, ['list'])
1087+
print(result.output)
1088+
assert result.output.startswith('Today, 2019-01-21')

0 commit comments

Comments
 (0)