author | Alexandre Fayolle <alexandre.fayolle@logilab.fr> |
Wed, 14 Oct 2009 14:09:40 +0200 | |
branch | stable |
changeset 3668 | 365c5be5b43f |
parent 1977 | 606923dff11b |
child 2773 | b2530e3e0afb |
permissions | -rw-r--r-- |
0 | 1 |
"""cubicweb.web.controller unit tests |
2 |
||
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1654
diff
changeset
|
3 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 4 |
""" |
5 |
||
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
6 |
from datetime import datetime, date, time |
0 | 7 |
|
8 |
from logilab.common.testlib import unittest_main |
|
9 |
||
10 |
from cubicweb.devtools import apptest |
|
11 |
||
12 |
class BaseControllerTC(apptest.ControllerTC): |
|
1654 | 13 |
|
14 |
def test_parse_datetime_ok(self): |
|
15 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24 12:18'), |
|
16 |
datetime) |
|
17 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24'), |
|
18 |
date) |
|
19 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24 12:18', 'Datetime'), |
|
20 |
datetime) |
|
21 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24', 'Datetime'), |
|
22 |
datetime) |
|
23 |
self.assertIsInstance(self.ctrl.parse_datetime('2006/06/24', 'Date'), |
|
24 |
date) |
|
25 |
self.assertIsInstance(self.ctrl.parse_datetime('12:18', 'Time'), |
|
26 |
time) |
|
27 |
||
28 |
def test_parse_datetime_ko(self): |
|
0 | 29 |
self.assertRaises(ValueError, |
30 |
self.ctrl.parse_datetime, '2006/06/24 12:188', 'Datetime') |
|
31 |
self.assertRaises(ValueError, |
|
32 |
self.ctrl.parse_datetime, '2006/06/240', 'Datetime') |
|
33 |
self.assertRaises(ValueError, |
|
34 |
self.ctrl.parse_datetime, '2006/06/24 12:18', 'Date') |
|
35 |
self.assertRaises(ValueError, |
|
36 |
self.ctrl.parse_datetime, '2006/24/06', 'Date') |
|
37 |
self.assertRaises(ValueError, |
|
38 |
self.ctrl.parse_datetime, '2006/06/240', 'Date') |
|
39 |
self.assertRaises(ValueError, |
|
40 |
self.ctrl.parse_datetime, '12:188', 'Time') |
|
1654 | 41 |
|
0 | 42 |
if __name__ == '__main__': |
43 |
unittest_main() |