1 from logilab.common.testlib import unittest_main |
|
2 from cubicweb.devtools.apptest import EnvBasedTC |
|
3 |
|
4 from cubicweb.common.rest import rest_publish |
|
5 |
|
6 class RestTC(EnvBasedTC): |
|
7 def context(self): |
|
8 return self.execute('CWUser X WHERE X login "admin"').get_entity(0, 0) |
|
9 |
|
10 def test_eid_role(self): |
|
11 context = self.context() |
|
12 self.assertEquals(rest_publish(context, ':eid:`%s`' % context.eid), |
|
13 '<p><a class="reference" href="http://testing.fr/cubicweb/euser/admin">#%s</a></p>\n' % context.eid) |
|
14 self.assertEquals(rest_publish(context, ':eid:`%s:some text`' % context.eid), |
|
15 '<p><a class="reference" href="http://testing.fr/cubicweb/euser/admin">some text</a></p>\n') |
|
16 |
|
17 def test_card_role_create(self): |
|
18 self.assertEquals(rest_publish(self.context(), ':card:`index`'), |
|
19 '<p><a class="reference" href="http://testing.fr/cubicweb/view?etype=Card&wikiid=index&vid=creation">index</a></p>\n') |
|
20 |
|
21 def test_card_role_link(self): |
|
22 self.add_entity('Card', wikiid=u'index', title=u'Site index page', synopsis=u'yo') |
|
23 self.assertEquals(rest_publish(self.context(), ':card:`index`'), |
|
24 '<p><a class="reference" href="http://testing.fr/cubicweb/card/index">index</a></p>\n') |
|
25 |
|
26 def test_bad_rest_no_crash(self): |
|
27 data = rest_publish(self.context(), ''' |
|
28 | card | implication | |
|
29 -------------------------- |
|
30 | 1-1 | N1 = N2 | |
|
31 | 1-? | N1 <= N2 | |
|
32 | 1-+ | N1 >= N2 | |
|
33 | 1-* | N1>0 => N2>0 | |
|
34 -------------------------- |
|
35 | ?-? | N1 # N2 | |
|
36 | ?-+ | N1 >= N2 | |
|
37 | ?-* | N1 # N2 | |
|
38 -------------------------- |
|
39 | +-+ | N1>0 => N2>0 et | |
|
40 | | N2>0 => N1>0 | |
|
41 | +-* | N1>+ => N2>0 | |
|
42 -------------------------- |
|
43 | *-* | N1#N2 | |
|
44 -------------------------- |
|
45 |
|
46 ''') |
|
47 |
|
48 if __name__ == '__main__': |
|
49 unittest_main() |
|