Commit e39ae41e authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[test] use assertCountEqual instead of assertItemsEqual

--HG--
branch : stable
parent 68744f5154c4
......@@ -434,12 +434,12 @@ class MigrationCommandsTC(CubicWebTC):
self.mh.commit()
# unique_together test
self.assertEqual(len(self.schema.eschema('Personne')._unique_together), 1)
self.assertItemsEqual(self.schema.eschema('Personne')._unique_together[0],
self.assertCountEqual(self.schema.eschema('Personne')._unique_together[0],
('nom', 'prenom', 'datenaiss'))
rset = cursor.execute('Any C WHERE C is CWUniqueTogetherConstraint, C constraint_of ET, ET name "Personne"')
self.assertEqual(len(rset), 1)
relations = [r.name for r in rset.get_entity(0, 0).relations]
self.assertItemsEqual(relations, ('nom', 'prenom', 'datenaiss'))
self.assertCountEqual(relations, ('nom', 'prenom', 'datenaiss'))
def _erqlexpr_rset(self, action, ertype):
rql = 'RQLExpression X WHERE ET is CWEType, ET %s_permission X, ET name %%(name)s' % action
......
......@@ -150,24 +150,24 @@ class EntityTC(CubicWebTC):
p1 = req.create_entity('Personne', nom=u'di')
p2 = req.create_entity('Personne', nom=u'mascio')
t = req.create_entity('Tag', name=u't0', tags=[])
self.assertItemsEqual(t.tags, [])
self.assertCountEqual(t.tags, [])
t = req.create_entity('Tag', name=u't1', tags=p1)
self.assertItemsEqual(t.tags, [p1])
self.assertCountEqual(t.tags, [p1])
t = req.create_entity('Tag', name=u't2', tags=p1.eid)
self.assertItemsEqual(t.tags, [p1])
self.assertCountEqual(t.tags, [p1])
t = req.create_entity('Tag', name=u't3', tags=[p1, p2.eid])
self.assertItemsEqual(t.tags, [p1, p2])
self.assertCountEqual(t.tags, [p1, p2])
def test_cw_instantiate_reverse_relation(self):
req = self.request()
t1 = req.create_entity('Tag', name=u't1')
t2 = req.create_entity('Tag', name=u't2')
p = req.create_entity('Personne', nom=u'di mascio', reverse_tags=t1)
self.assertItemsEqual(p.reverse_tags, [t1])
self.assertCountEqual(p.reverse_tags, [t1])
p = req.create_entity('Personne', nom=u'di mascio', reverse_tags=t1.eid)
self.assertItemsEqual(p.reverse_tags, [t1])
self.assertCountEqual(p.reverse_tags, [t1])
p = req.create_entity('Personne', nom=u'di mascio', reverse_tags=[t1, t2.eid])
self.assertItemsEqual(p.reverse_tags, [t1, t2])
self.assertCountEqual(p.reverse_tags, [t1, t2])
def test_fetch_rql(self):
user = self.user()
......
......@@ -85,15 +85,15 @@ class DefinitionOrderTC(CubicWebTC):
def test_uihelper_hide_fields(self):
# original conf : in_group is edited in 'attributes' section everywhere
section_conf = uicfg.autoform_section.get('CWUser', 'in_group', '*', 'subject')
self.assertItemsEqual(section_conf, ['main_attributes', 'muledit_attributes'])
self.assertCountEqual(section_conf, ['main_attributes', 'muledit_attributes'])
# hide field in main form
uihelper.hide_fields('CWUser', ('login', 'in_group'))
section_conf = uicfg.autoform_section.get('CWUser', 'in_group', '*', 'subject')
self.assertItemsEqual(section_conf, ['main_hidden', 'muledit_attributes'])
self.assertCountEqual(section_conf, ['main_hidden', 'muledit_attributes'])
# hide field in muledit form
uihelper.hide_fields('CWUser', ('login', 'in_group'), formtype='muledit')
section_conf = uicfg.autoform_section.get('CWUser', 'in_group', '*', 'subject')
self.assertItemsEqual(section_conf, ['main_hidden', 'muledit_hidden'])
self.assertCountEqual(section_conf, ['main_hidden', 'muledit_hidden'])
@tag('uihelper', 'hidden', 'formconfig')
def test_uihelper_formconfig(self):
......@@ -103,7 +103,7 @@ class DefinitionOrderTC(CubicWebTC):
hidden = ('in_group',)
fields_order = ('login', 'firstname')
section_conf = uicfg.autoform_section.get('CWUser', 'in_group', '*', 'subject')
self.assertItemsEqual(section_conf, ['main_hidden', 'muledit_attributes'])
self.assertCountEqual(section_conf, ['main_hidden', 'muledit_attributes'])
self.assertEqual(afk_get('CWUser', 'firstname', 'String', 'subject'), {'order': 1})
......
......@@ -397,7 +397,7 @@ class EditControllerTC(CubicWebTC):
path, params = self.expect_redirect_handle_request(req, 'edit')
usergroups = [gname for gname, in
self.execute('Any N WHERE G name N, U in_group G, U eid %(u)s', {'u': user.eid})]
self.assertItemsEqual(usergroups, ['managers', 'test'])
self.assertCountEqual(usergroups, ['managers', 'test'])
self.assertEqual(get_pending_inserts(req), [])
def test_req_pending_delete(self):
......@@ -408,14 +408,14 @@ class EditControllerTC(CubicWebTC):
usergroups = [gname for gname, in
self.execute('Any N WHERE G name N, U in_group G, U eid %(u)s', {'u': user.eid})]
# just make sure everything was set correctly
self.assertItemsEqual(usergroups, ['managers', 'test'])
self.assertCountEqual(usergroups, ['managers', 'test'])
# now try to delete the relation
req = self.request(**req_form(user))
req.session.data['pending_delete'] = set([(user.eid, 'in_group', groupeid)])
path, params = self.expect_redirect_handle_request(req, 'edit')
usergroups = [gname for gname, in
self.execute('Any N WHERE G name N, U in_group G, U eid %(u)s', {'u': user.eid})]
self.assertItemsEqual(usergroups, ['managers'])
self.assertCountEqual(usergroups, ['managers'])
self.assertEqual(get_pending_deletes(req), [])
def test_redirect_apply_button(self):
......@@ -715,7 +715,7 @@ class AjaxControllerTC(CubicWebTC):
def test_remote_add_existing_tag(self):
self.remote_call('tag_entity', self.john.eid, ['python'])
self.assertItemsEqual(
self.assertCountEqual(
[tname for tname, in self.execute('Any N WHERE T is Tag, T name N')],
['python', 'cubicweb'])
self.assertEqual(
......@@ -724,7 +724,7 @@ class AjaxControllerTC(CubicWebTC):
def test_remote_add_new_tag(self):
self.remote_call('tag_entity', self.john.eid, ['javascript'])
self.assertItemsEqual(
self.assertCountEqual(
[tname for tname, in self.execute('Any N WHERE T is Tag, T name N')],
['python', 'cubicweb', 'javascript'])
self.assertEqual(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment