author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Mon, 18 May 2009 19:50:23 +0200 | |
branch | stable |
changeset 1850 | 75661f0a691b |
parent 1802 | d628defebc17 |
child 1977 | 606923dff11b |
permissions | -rw-r--r-- |
0 | 1 |
from cubicweb.goa.testlib import * |
2 |
||
3 |
from cubicweb.interfaces import ICalendarable |
|
4 |
||
5 |
||
6 |
class Blog(db.Model): |
|
7 |
diem = db.DateProperty(required=True, auto_now_add=True) |
|
8 |
title = db.StringProperty(required=True) |
|
9 |
content = db.TextProperty() |
|
10 |
||
11 |
__implements__ = (ICalendarable,) |
|
12 |
||
13 |
@property |
|
14 |
def start(self): |
|
15 |
return self.diem |
|
16 |
||
17 |
@property |
|
18 |
def stop(self): |
|
19 |
return self.diem |
|
20 |
||
21 |
def matching_dates(self, begin, end): |
|
22 |
"""calendar views interface""" |
|
23 |
mydate = self.diem |
|
24 |
if mydate: |
|
25 |
return [mydate] |
|
26 |
return [] |
|
27 |
||
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
28 |
|
0 | 29 |
class SomeViewsTC(GAEBasedTC): |
30 |
MODEL_CLASSES = (Blog, ) |
|
31 |
from cubicweb.web.views import basecontrollers, baseviews, navigation, boxes, calendar |
|
32 |
from data import views |
|
33 |
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
|
34 |
|
0 | 35 |
def setUp(self): |
36 |
GAEBasedTC.setUp(self) |
|
37 |
self.req = self.request() |
|
38 |
self.blog = Blog(title=u'a blog', content=u'hop') |
|
39 |
self.blog.put(self.req) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
40 |
|
0 | 41 |
def test_hcal(self): |
42 |
self.vreg.render('views', '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
|
43 |
|
0 | 44 |
def test_django_index(self): |
45 |
self.vreg.render('views', 'index', self.req, rset=None) |
|
46 |
||
47 |
for vid in ('primary', 'secondary', 'oneline', 'incontext', 'outofcontext', 'text'): |
|
48 |
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
|
49 |
|
0 | 50 |
if __name__ == '__main__': |
51 |
from logilab.common.testlib import unittest_main |
|
52 |
unittest_main() |