1 """cubicweb.web.views.baseforms unit tests""" |
1 """cubicweb.web.views.baseforms unit tests""" |
2 |
2 |
3 from StringIO import StringIO |
3 from StringIO import StringIO |
4 import re |
4 import re |
5 |
5 |
|
6 from mx.DateTime import DateTime |
|
7 |
6 from logilab.common.testlib import unittest_main |
8 from logilab.common.testlib import unittest_main |
|
9 from logilab.common.decorators import clear_cache |
7 from cubicweb.devtools.apptest import EnvBasedTC |
10 from cubicweb.devtools.apptest import EnvBasedTC |
8 |
|
9 from cubicweb.entities import AnyEntity |
11 from cubicweb.entities import AnyEntity |
10 |
|
11 from mx.DateTime import DateTime |
|
12 from cubicweb.web import widgets |
12 from cubicweb.web import widgets |
|
13 |
13 orig_today = widgets.today |
14 orig_today = widgets.today |
14 orig_now = widgets.now |
15 orig_now = widgets.now |
15 |
16 |
16 def setup_module(options): |
17 def setup_module(options): |
17 def _today(): |
18 def _today(): |
18 return DateTime(0000, 1, 1) |
19 return DateTime(0000, 1, 1) |
19 widgets.today = widgets.now = _today |
20 widgets.today = widgets.now = _today |
20 |
21 |
21 def teardown_module(options): |
22 def teardown_module(options, result): |
22 widgets.today = orig_today |
23 widgets.today = orig_today |
23 widgets.now = orig_now |
24 widgets.now = orig_now |
24 |
25 |
25 |
26 |
26 def cleanup_text(text): |
27 def cleanup_text(text): |
205 def test_nonregr_check_add_permission_on_relation(self): |
206 def test_nonregr_check_add_permission_on_relation(self): |
206 from cubes.blog.entities import BlogEntry |
207 from cubes.blog.entities import BlogEntry |
207 class BlogEntryPlus(BlogEntry): |
208 class BlogEntryPlus(BlogEntry): |
208 __rtags__ = {'checked_by': 'primary'} |
209 __rtags__ = {'checked_by': 'primary'} |
209 self.vreg.register_vobject_class(BlogEntryPlus) |
210 self.vreg.register_vobject_class(BlogEntryPlus) |
|
211 clear_cache(self.vreg, 'etype_class') |
210 # an admin should be able to edit the checked_by relation |
212 # an admin should be able to edit the checked_by relation |
211 html = self._build_creation_form('BlogEntry') |
213 html = self._build_creation_form('BlogEntry') |
212 self.failUnless('name="edits-checked_by:A"' in html) |
214 self.failUnless('name="edits-checked_by:A"' in html) |
213 # a regular user should not be able to see the relation |
215 # a regular user should not be able to see the relation |
214 self.login('joe') |
216 self.login('joe') |