|
1 """cubicweb.web.controller unit tests |
|
2 |
|
3 """ |
|
4 |
|
5 from mx.DateTime import DateTimeType, DateTimeDeltaType |
|
6 |
|
7 from logilab.common.testlib import unittest_main |
|
8 |
|
9 from cubicweb.devtools import apptest |
|
10 |
|
11 class BaseControllerTC(apptest.ControllerTC): |
|
12 def test_parse_datetime(self): |
|
13 self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24 12:18'), DateTimeType) |
|
14 self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24'), DateTimeType) |
|
15 self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24 12:18', 'Datetime'), DateTimeType) |
|
16 self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24', 'Datetime'), DateTimeType) |
|
17 self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24', 'Date'), DateTimeType) |
|
18 self.assertIsInstance(self.ctrl.parse_datetime('12:18', 'Time'), DateTimeDeltaType) |
|
19 self.assertRaises(ValueError, |
|
20 self.ctrl.parse_datetime, '2006/06/24 12:188', 'Datetime') |
|
21 self.assertRaises(ValueError, |
|
22 self.ctrl.parse_datetime, '2006/06/240', 'Datetime') |
|
23 self.assertRaises(ValueError, |
|
24 self.ctrl.parse_datetime, '2006/06/24 12:18', 'Date') |
|
25 self.assertRaises(ValueError, |
|
26 self.ctrl.parse_datetime, '2006/24/06', 'Date') |
|
27 self.assertRaises(ValueError, |
|
28 self.ctrl.parse_datetime, '2006/06/240', 'Date') |
|
29 self.assertRaises(ValueError, |
|
30 self.ctrl.parse_datetime, '12:188', 'Time') |
|
31 |
|
32 if __name__ == '__main__': |
|
33 unittest_main() |