78 with self.admin_access.repo_cnx() as cnx: |
78 with self.admin_access.repo_cnx() as cnx: |
79 cnx.execute('INSERT CWProperty X: X pkey "test.int", X value "42"') |
79 cnx.execute('INSERT CWProperty X: X pkey "test.int", X value "42"') |
80 cnx.commit() |
80 cnx.commit() |
81 self.assertEqual(self.vreg.property_value('test.int'), 42) |
81 self.assertEqual(self.vreg.property_value('test.int'), 42) |
82 |
82 |
83 def test_sync_user_props(self): |
|
84 with self.admin_access.client_cnx() as cnx: |
|
85 self.assertNotIn('ui.language', cnx.user.properties) |
|
86 cnx.user.set_property(u'ui.language', u'fr') |
|
87 self.assertNotIn('ui.language', cnx.user.properties) |
|
88 cnx.commit() |
|
89 self.assertEqual(cnx.user.properties['ui.language'], 'fr') |
|
90 cnx.user.set_property(u'ui.language', u'en') |
|
91 self.assertEqual(cnx.user.properties['ui.language'], 'fr') |
|
92 cnx.commit() |
|
93 self.assertEqual(cnx.user.properties['ui.language'], 'en') |
|
94 cnx.execute('DELETE CWProperty X WHERE X for_user U, U eid %(u)s', |
|
95 {'u': cnx.user.eid}) |
|
96 self.assertEqual(cnx.user.properties['ui.language'], 'en') |
|
97 cnx.commit() |
|
98 self.assertNotIn('ui.language', cnx.user.properties) |
|
99 |
|
100 def test_sync_sitewide_props(self): |
83 def test_sync_sitewide_props(self): |
101 with self.admin_access.client_cnx() as cnx: |
84 with self.admin_access.client_cnx() as cnx: |
102 self.assertNotIn('ui.language', cnx.vreg['propertyvalues']) |
85 self.assertNotIn('ui.language', cnx.vreg['propertyvalues']) |
103 cwprop = cnx.create_entity('CWProperty', pkey=u'ui.language', value=u'fr') |
86 cwprop = cnx.create_entity('CWProperty', pkey=u'ui.language', value=u'fr') |
104 self.assertNotIn('ui.language', cnx.vreg['propertyvalues']) |
87 self.assertNotIn('ui.language', cnx.vreg['propertyvalues']) |
112 self.assertEqual(cnx.vreg['propertyvalues']['ui.language'], 'en') |
95 self.assertEqual(cnx.vreg['propertyvalues']['ui.language'], 'en') |
113 cnx.commit() |
96 cnx.commit() |
114 self.assertNotIn('ui.language', cnx.vreg['propertyvalues']) |
97 self.assertNotIn('ui.language', cnx.vreg['propertyvalues']) |
115 |
98 |
116 |
99 |
117 class UserGroupsSyncTC(CubicWebTC): |
|
118 |
|
119 def test_sync_groups(self): |
|
120 with self.admin_access.client_cnx() as cnx: |
|
121 cnx.execute('SET U in_group G WHERE G name "users", U eid %(u)s', |
|
122 {'u': cnx.user.eid}) |
|
123 self.assertEqual(cnx.user.groups, set(['managers'])) |
|
124 cnx.commit() |
|
125 self.assertEqual(cnx.user.groups, set(['managers', 'users'])) |
|
126 cnx.execute('DELETE U in_group G WHERE G name "users", U eid %(u)s', |
|
127 {'u': cnx.user.eid}) |
|
128 self.assertEqual(cnx.user.groups, set(['managers', 'users'])) |
|
129 cnx.commit() |
|
130 self.assertEqual(cnx.user.groups, set(['managers'])) |
|
131 |
|
132 |
|
133 if __name__ == '__main__': |
100 if __name__ == '__main__': |
134 import unittest |
101 import unittest |
135 unittest.main() |
102 unittest.main() |