author | Julien Jehannet <julien.jehannet@logilab.fr> |
Thu, 22 Apr 2010 17:04:51 +0200 | |
changeset 5373 | 24a873060692 |
parent 3460 | e4843535db25 |
child 5421 | 8167de96c523 |
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 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
10 |
from cubicweb.devtools import testlib |
0 | 11 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
12 |
class BaseControllerTC(testlib.CubicWebTC): |
1654 | 13 |
|
14 |
def test_parse_datetime_ok(self): |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
15 |
ctrl = self.vreg['controllers'].select('view', self.request()) |
3460
e4843535db25
[api] some more _cw / __regid__, automatic tests now pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2773
diff
changeset
|
16 |
pd = ctrl._cw.parse_datetime |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
17 |
self.assertIsInstance(pd('2006/06/24 12:18'), datetime) |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
18 |
self.assertIsInstance(pd('2006/06/24'), date) |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
19 |
self.assertIsInstance(pd('2006/06/24 12:18', 'Datetime'), datetime) |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
20 |
self.assertIsInstance(pd('2006/06/24', 'Datetime'), datetime) |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
21 |
self.assertIsInstance(pd('2006/06/24', 'Date'), date) |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
22 |
self.assertIsInstance(pd('12:18', 'Time'), time) |
1654 | 23 |
|
24 |
def test_parse_datetime_ko(self): |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
25 |
ctrl = self.vreg['controllers'].select('view', self.request()) |
3460
e4843535db25
[api] some more _cw / __regid__, automatic tests now pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2773
diff
changeset
|
26 |
pd = ctrl._cw.parse_datetime |
0 | 27 |
self.assertRaises(ValueError, |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
28 |
pd, '2006/06/24 12:188', 'Datetime') |
0 | 29 |
self.assertRaises(ValueError, |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
30 |
pd, '2006/06/240', 'Datetime') |
0 | 31 |
self.assertRaises(ValueError, |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
32 |
pd, '2006/06/24 12:18', 'Date') |
0 | 33 |
self.assertRaises(ValueError, |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
34 |
pd, '2006/24/06', 'Date') |
0 | 35 |
self.assertRaises(ValueError, |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
36 |
pd, '2006/06/240', 'Date') |
0 | 37 |
self.assertRaises(ValueError, |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
38 |
pd, '12:188', 'Time') |
1654 | 39 |
|
0 | 40 |
if __name__ == '__main__': |
41 |
unittest_main() |