1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
3 # |
|
4 # This file is part of CubicWeb. |
|
5 # |
|
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
|
7 # terms of the GNU Lesser General Public License as published by the Free |
|
8 # Software Foundation, either version 2.1 of the License, or (at your option) |
|
9 # any later version. |
|
10 # |
|
11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
|
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
|
14 # details. |
|
15 # |
|
16 # You should have received a copy of the GNU Lesser General Public License along |
|
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
|
18 """ |
|
19 |
|
20 """ |
|
21 from cubicweb.goa.testlib import * |
|
22 |
|
23 from cubicweb.interfaces import ICalendarable |
|
24 |
|
25 |
|
26 class Blog(db.Model): |
|
27 diem = db.DateProperty(required=True, auto_now_add=True) |
|
28 title = db.StringProperty(required=True) |
|
29 content = db.TextProperty() |
|
30 |
|
31 __implements__ = (ICalendarable,) |
|
32 |
|
33 @property |
|
34 def start(self): |
|
35 return self.diem |
|
36 |
|
37 @property |
|
38 def stop(self): |
|
39 return self.diem |
|
40 |
|
41 def matching_dates(self, begin, end): |
|
42 """calendar views interface""" |
|
43 mydate = self.diem |
|
44 if mydate: |
|
45 return [mydate] |
|
46 return [] |
|
47 |
|
48 |
|
49 class SomeViewsTC(GAEBasedTC): |
|
50 MODEL_CLASSES = (Blog, ) |
|
51 from cubicweb.web.views import basecontrollers, baseviews, navigation, boxes, calendar |
|
52 from data import views |
|
53 LOAD_APP_MODULES = (basecontrollers, baseviews, navigation, boxes, calendar, views) |
|
54 |
|
55 def setUp(self): |
|
56 GAEBasedTC.setUp(self) |
|
57 self.req = self.request() |
|
58 self.blog = Blog(title=u'a blog', content=u'hop') |
|
59 self.blog.put(self.req) |
|
60 |
|
61 def test_hcal(self): |
|
62 self.vreg['views'].render('hcal', self.req, rset=self.blog.rset) |
|
63 |
|
64 def test_django_index(self): |
|
65 self.vreg['views'].render('index', self.req, rset=None) |
|
66 |
|
67 for vid in ('primary', 'oneline', 'incontext', 'outofcontext', 'text'): |
|
68 setattr(SomeViewsTC, 'test_%s'%vid, lambda self, vid=vid: self.blog.view(vid)) |
|
69 |
|
70 if __name__ == '__main__': |
|
71 from logilab.common.testlib import unittest_main |
|
72 unittest_main() |
|