author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 26 May 2009 18:22:24 +0200 | |
branch | stable |
changeset 1943 | fb557b616c80 |
parent 1654 | 57b9fd2462b8 |
child 1977 | 606923dff11b |
permissions | -rw-r--r-- |
0 | 1 |
"""cubicweb.web.controller unit tests |
2 |
||
3 |
""" |
|
4 |
||
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
5 |
from datetime import datetime, date, time |
0 | 6 |
|
7 |
from logilab.common.testlib import unittest_main |
|
8 |
||
9 |
from cubicweb.devtools import apptest |
|
10 |
||
11 |
class BaseControllerTC(apptest.ControllerTC): |
|
1654 | 12 |
|
13 |
def test_parse_datetime_ok(self): |
|
14 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24 12:18'), |
|
15 |
datetime) |
|
16 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24'), |
|
17 |
date) |
|
18 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24 12:18', 'Datetime'), |
|
19 |
datetime) |
|
20 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24', 'Datetime'), |
|
21 |
datetime) |
|
22 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24', 'Date'), |
|
23 |
date) |
|
24 |
self.assertIsInstance(self.ctrl.parse_datetime('12:18', 'Time'), |
|
25 |
time) |
|
26 |
||
27 |
def test_parse_datetime_ko(self): |
|
0 | 28 |
self.assertRaises(ValueError, |
29 |
self.ctrl.parse_datetime, '2006/06/24 12:188', 'Datetime') |
|
30 |
self.assertRaises(ValueError, |
|
31 |
self.ctrl.parse_datetime, '2006/06/240', 'Datetime') |
|
32 |
self.assertRaises(ValueError, |
|
33 |
self.ctrl.parse_datetime, '2006/06/24 12:18', 'Date') |
|
34 |
self.assertRaises(ValueError, |
|
35 |
self.ctrl.parse_datetime, '2006/24/06', 'Date') |
|
36 |
self.assertRaises(ValueError, |
|
37 |
self.ctrl.parse_datetime, '2006/06/240', 'Date') |
|
38 |
self.assertRaises(ValueError, |
|
39 |
self.ctrl.parse_datetime, '12:188', 'Time') |
|
1654 | 40 |
|
0 | 41 |
if __name__ == '__main__': |
42 |
unittest_main() |