author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 23 Sep 2009 19:16:44 +0200 | |
changeset 3445 | 32492e9e734b |
parent 2729 | d3dbd135f319 |
child 4212 | ab6573088b4a |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
1 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
3 |
:organization: Logilab |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
7 |
""" |
0 | 8 |
from cubicweb.goa.testlib import * |
9 |
||
10 |
from cubicweb.interfaces import ICalendarable |
|
11 |
||
12 |
||
13 |
class Blog(db.Model): |
|
14 |
diem = db.DateProperty(required=True, auto_now_add=True) |
|
15 |
title = db.StringProperty(required=True) |
|
16 |
content = db.TextProperty() |
|
17 |
||
18 |
__implements__ = (ICalendarable,) |
|
19 |
||
20 |
@property |
|
21 |
def start(self): |
|
22 |
return self.diem |
|
23 |
||
24 |
@property |
|
25 |
def stop(self): |
|
26 |
return self.diem |
|
27 |
||
28 |
def matching_dates(self, begin, end): |
|
29 |
"""calendar views interface""" |
|
30 |
mydate = self.diem |
|
31 |
if mydate: |
|
32 |
return [mydate] |
|
33 |
return [] |
|
34 |
||
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
35 |
|
0 | 36 |
class SomeViewsTC(GAEBasedTC): |
37 |
MODEL_CLASSES = (Blog, ) |
|
38 |
from cubicweb.web.views import basecontrollers, baseviews, navigation, boxes, calendar |
|
39 |
from data import views |
|
40 |
LOAD_APP_MODULES = (basecontrollers, baseviews, navigation, boxes, calendar, views) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
41 |
|
0 | 42 |
def setUp(self): |
43 |
GAEBasedTC.setUp(self) |
|
44 |
self.req = self.request() |
|
45 |
self.blog = Blog(title=u'a blog', content=u'hop') |
|
46 |
self.blog.put(self.req) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
47 |
|
0 | 48 |
def test_hcal(self): |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2471
diff
changeset
|
49 |
self.vreg['views'].render('hcal', self.req, rset=self.blog.rset) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
50 |
|
0 | 51 |
def test_django_index(self): |
2729
d3dbd135f319
fix syntax error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
52 |
self.vreg['views'].render('index', self.req, rset=None) |
0 | 53 |
|
2471
3e2b50ece726
begin to drop ref to secondary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
54 |
for vid in ('primary', 'oneline', 'incontext', 'outofcontext', 'text'): |
0 | 55 |
setattr(SomeViewsTC, 'test_%s'%vid, lambda self, vid=vid: self.blog.view(vid)) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
56 |
|
0 | 57 |
if __name__ == '__main__': |
58 |
from logilab.common.testlib import unittest_main |
|
59 |
unittest_main() |