Skip to content

Commit 47364e2

Browse files
committed
Added tests for commit datetime handling.
1 parent b84df09 commit 47364e2

1 file changed

Lines changed: 54 additions & 1 deletion

File tree

tests/test_date_handling.py

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
from nose.tools import assert_equals
88

9-
from github2.core import (ghdate_to_datetime, datetime_to_ghdate)
9+
from github2.core import (ghdate_to_datetime, datetime_to_ghdate,
10+
commitdate_to_datetime, datetime_to_commitdate)
1011

1112

1213
# Commented test cases are in PST, and aren't correctly handled with the
@@ -62,3 +63,55 @@ def test_datetime_to_ghdate():
6263
'2010/07/28 19:56:51 -0700')
6364
assert_equals(datetime_to_ghdate(dt(2010, 9, 21, 4, 32, 49)),
6465
'2010/09/21 04:32:49 -0700')
66+
67+
68+
def test_commitdate_to_datetime():
69+
assert_equals(commitdate_to_datetime('2011-05-22T00:24:15-07:00'),
70+
dt(2011, 5, 22, 0, 24, 15))
71+
72+
assert_equals(commitdate_to_datetime('2011-04-09T10:07:30-07:00'),
73+
dt(2011, 4, 9, 10, 7, 30))
74+
#assert_equals(commitdate_to_datetime('2011-02-19T07:16:11-08:00'),
75+
# dt(2011, 2, 19, 7, 16, 11))
76+
#assert_equals(commitdate_to_datetime('2010-12-21T12:34:27-08:00'),
77+
# dt(2010, 12, 21, 12, 34, 27))
78+
assert_equals(commitdate_to_datetime('2011-04-09T10:20:05-07:00'),
79+
dt(2011, 4, 9, 10, 20, 5))
80+
assert_equals(commitdate_to_datetime('2011-04-09T10:05:58-07:00'),
81+
dt(2011, 4, 9, 10, 5, 58))
82+
assert_equals(commitdate_to_datetime('2011-04-09T09:53:00-07:00'),
83+
dt(2011, 4, 9, 9, 53, 0))
84+
assert_equals(commitdate_to_datetime('2011-04-09T10:00:21-07:00'),
85+
dt(2011, 4, 9, 10, 0, 21))
86+
#assert_equals(commitdate_to_datetime('2010-12-16T15:10:59-08:00'),
87+
# dt(2010, 12, 16, 15, 10, 59))
88+
assert_equals(commitdate_to_datetime('2011-04-09T09:53:00-07:00'),
89+
dt(2011, 4, 9, 9, 53, 0))
90+
assert_equals(commitdate_to_datetime('2011-04-09T09:53:00-07:00'),
91+
dt(2011, 4, 9, 9, 53, 0))
92+
93+
94+
def test_datetime_to_commitdate():
95+
assert_equals(datetime_to_commitdate(dt(2011, 5, 22, 0, 24, 15)),
96+
'2011-05-22T00:24:15-07:00')
97+
98+
assert_equals(datetime_to_commitdate(dt(2011, 4, 9, 10, 7, 30)),
99+
'2011-04-09T10:07:30-07:00')
100+
#assert_equals(datetime_to_commitdate(dt(2011, 2, 19, 7, 16, 11)),
101+
# '2011-02-19T07:16:11-08:00')
102+
#assert_equals(datetime_to_commitdate(dt(2010, 12, 21, 12, 34, 27)),
103+
# '2010-12-21T12:34:27-08:00')
104+
assert_equals(datetime_to_commitdate(dt(2011, 4, 9, 10, 20, 5)),
105+
'2011-04-09T10:20:05-07:00')
106+
assert_equals(datetime_to_commitdate(dt(2011, 4, 9, 10, 5, 58)),
107+
'2011-04-09T10:05:58-07:00')
108+
assert_equals(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)),
109+
'2011-04-09T09:53:00-07:00')
110+
assert_equals(datetime_to_commitdate(dt(2011, 4, 9, 10, 0, 21)),
111+
'2011-04-09T10:00:21-07:00')
112+
#assert_equals(datetime_to_commitdate(dt(2010, 12, 16, 15, 10, 59)),
113+
# '2010-12-16T15:10:59-08:00')
114+
assert_equals(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)),
115+
'2011-04-09T09:53:00-07:00')
116+
assert_equals(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)),
117+
'2011-04-09T09:53:00-07:00')

0 commit comments

Comments
 (0)