author | Florent <florent@secondweb.fr> |
Mon, 27 Apr 2009 19:01:00 +0200 | |
branch | tls-sprint |
changeset 1488 | 6da89a703c5a |
parent 1016 | 26387b836099 |
child 1654 | 57b9fd2462b8 |
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): |
|
12 |
def test_parse_datetime(self): |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
13 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24 12:18'), datetime) |
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
14 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24'), datetime) |
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
15 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24 12:18', 'Datetime'), datetime) |
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
16 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24', 'Datetime'), datetime) |
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
17 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24', 'Date'), date) |
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
18 |
self.assertIsInstance(self.ctrl.parse_datetime('12:18', 'Time'), time) |
0 | 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() |