forked from joh/gnome-shell-google-calendar
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathtest
executable file
·48 lines (37 loc) · 1.43 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
#
# Unit tests for gnome-shell-google-calendar
import unittest
import datetime
# remove the copied module
def cleanup():
import os
os.remove('gsgc_test.py')
if os.path.exists('gsgc_test.pyc'):
os.remove('gsgc_test.pyc')
import atexit
atexit.register(cleanup)
# import, but have to use a python-compatible name
import shutil
shutil.copy('gnome-shell-google-calendar.py', 'gsgc_test.py')
import gsgc_test as gsgc
#################################################
class TestGnomeGoogleCalendar(unittest.TestCase):
def test_GetMonthKey(self):
from time import strftime, localtime
def tostr(x):
return [strftime('%Y%m%d %H%M%S', localtime(x)) for x in x]
self.assertEqual(tostr(
gsgc.get_month_key(datetime.datetime(2011, 12, 12))),
['20111127 000000', '20111231 235959'])
self.assertEqual(tostr(
gsgc.get_month_key(datetime.datetime(2011, 11, 1))),
['20111030 000000', '20111203 235959'])
self.assertEqual(tostr(
gsgc.get_month_key(datetime.datetime(2011, 1, 31))),
['20101226 000000', '20110205 235959'])
self.assertEqual(tostr(
gsgc.get_month_key(datetime.datetime(2012, 1, 31))),
['20120101 000000', '20120204 235959'])
suite = unittest.TestLoader().loadTestsFromTestCase(TestGnomeGoogleCalendar)
unittest.TextTestRunner(verbosity=2).run(suite)