1287
|
1 |
from logilab.common.testlib import unittest_main |
|
2 |
from cubicweb.devtools.apptest import EnvBasedTC |
|
3 |
from cubicweb.web.views.editforms import AutomaticEntityForm as AEF |
|
4 |
|
|
5 |
def rbc(entity, category): |
|
6 |
return [(rschema.type, x) for rschema, tschemas, x in AEF.erelations_by_category(entity, category)] |
|
7 |
|
|
8 |
class AutomaticEntityFormTC(EnvBasedTC): |
|
9 |
|
|
10 |
def test_euser_relations_by_category(self): |
|
11 |
#for (rtype, role, stype, otype), tag in AEF.rcategories._tagdefs.items(): |
|
12 |
# if rtype == 'tags': |
|
13 |
# print rtype, role, stype, otype, ':', tag |
|
14 |
e = self.etype_instance('EUser') |
|
15 |
# see custom configuration in views.euser |
|
16 |
self.assertEquals(rbc(e, 'primary'), |
|
17 |
[('login', 'subject'), |
|
18 |
('upassword', 'subject'), |
|
19 |
('in_group', 'subject'), |
|
20 |
('in_state', 'subject'), |
|
21 |
('eid', 'subject'), |
|
22 |
]) |
|
23 |
self.assertListEquals(rbc(e, 'secondary'), |
|
24 |
[('firstname', 'subject'), |
|
25 |
('surname', 'subject') |
|
26 |
]) |
|
27 |
self.assertListEquals(rbc(e, 'metadata'), |
|
28 |
[('last_login_time', 'subject'), |
|
29 |
('created_by', 'subject'), |
|
30 |
('creation_date', 'subject'), |
|
31 |
('modification_date', 'subject'), |
|
32 |
('owned_by', 'subject'), |
|
33 |
('bookmarked_by', 'object'), |
|
34 |
]) |
|
35 |
self.assertListEquals(rbc(e, 'generic'), |
|
36 |
[('primary_email', 'subject'), |
|
37 |
('use_email', 'subject'), |
|
38 |
('connait', 'subject'), |
|
39 |
('checked_by', 'object'), |
|
40 |
]) |
|
41 |
# owned_by is defined both as subject and object relations on EUser |
|
42 |
self.assertListEquals(rbc(e, 'generated'), |
|
43 |
[('is', 'subject'), |
|
44 |
('is_instance_of', 'subject'), |
|
45 |
('tags', 'object'), |
|
46 |
('for_user', 'object'), |
|
47 |
('created_by', 'object'), |
|
48 |
('wf_info_for', 'object'), |
|
49 |
('owned_by', 'object'), |
|
50 |
]) |
1298
|
51 |
|
|
52 |
def test_inlined_view(self): |
|
53 |
self.failUnless(AEF.rinlined.etype_rtag('EUser', 'use_email', 'subject')) |
|
54 |
self.failIf(AEF.rinlined.etype_rtag('EUser', 'primary_email', 'subject')) |
|
55 |
|
1287
|
56 |
def test_personne_relations_by_category(self): |
|
57 |
e = self.etype_instance('Personne') |
|
58 |
self.assertListEquals(rbc(e, 'primary'), |
|
59 |
[('nom', 'subject'), |
|
60 |
('eid', 'subject') |
|
61 |
]) |
|
62 |
self.assertListEquals(rbc(e, 'secondary'), |
|
63 |
[('prenom', 'subject'), |
|
64 |
('sexe', 'subject'), |
|
65 |
('promo', 'subject'), |
|
66 |
('titre', 'subject'), |
|
67 |
('ass', 'subject'), |
|
68 |
('web', 'subject'), |
|
69 |
('tel', 'subject'), |
|
70 |
('fax', 'subject'), |
|
71 |
('datenaiss', 'subject'), |
|
72 |
('test', 'subject'), |
|
73 |
('description', 'subject'), |
|
74 |
('salary', 'subject') |
|
75 |
]) |
|
76 |
self.assertListEquals(rbc(e, 'metadata'), |
|
77 |
[('created_by', 'subject'), |
|
78 |
('creation_date', 'subject'), |
|
79 |
('modification_date', 'subject'), |
|
80 |
('owned_by', 'subject'), |
|
81 |
]) |
|
82 |
self.assertListEquals(rbc(e, 'generic'), |
|
83 |
[('travaille', 'subject'), |
|
84 |
('connait', 'object') |
|
85 |
]) |
|
86 |
self.assertListEquals(rbc(e, 'generated'), |
|
87 |
[('is', 'subject'), |
|
88 |
('is_instance_of', 'subject'), |
|
89 |
]) |
|
90 |
if __name__ == '__main__': |
|
91 |
unittest_main() |