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

[ui] Fix bug in ContainedSearchForRelatedEntitiesView.linkable_rset

Closes #13853304
parent cf7b657ab058
......@@ -90,6 +90,42 @@ class PermissionsTC(CubicWebTC):
self.assertNotIn(field_name, bob_field_names)
class RelationWidgetTC(CubicWebTC):
"""Functional test case about the relation widget."""
def test_linkable_rset(self):
with self.admin_access.repo_cnx() as cnx:
transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'Test widget')
bdo = cnx.create_entity('SEDABinaryDataObject', id=u'bdo',
seda_binary_data_object=transfer)
bdo_alt = cnx.create_entity('SEDAAltBinaryDataObjectAttachment',
reverse_seda_alt_binary_data_object_attachment=bdo)
cnx.create_entity('SEDAAttachment', seda_attachment=bdo_alt)
compressed = cnx.create_entity('SEDACompressed', seda_compressed=bdo)
cnx.commit()
with self.admin_access.web_request() as req:
compressed = req.entity_from_eid(compressed.eid)
req.form = {'relation': 'seda_algorithm:Concept:subject',
'container': unicode(transfer.eid)}
view = self.vreg['views'].select('search_related_entities', req,
rset=compressed.as_rset())
self.failIf(view.linkable_rset())
with self.admin_access.repo_cnx() as cnx:
scheme = cnx.create_entity('ConceptScheme', title=u'CompressionAlgorithm')
scheme.add_concept(label=u'bz2')
cnx.create_entity('SEDACompressionAlgorithmCodeListVersion',
seda_compression_algorithm_code_list_version_from=transfer,
seda_compression_algorithm_code_list_version_to=scheme)
cnx.commit()
with self.admin_access.web_request() as req:
compressed = req.entity_from_eid(compressed.eid)
req.form = {'relation': 'seda_algorithm:Concept:subject',
'container': unicode(transfer.eid)}
view = self.vreg['views'].select('search_related_entities', req,
rset=compressed.as_rset())
self.assertEqual(len(view.linkable_rset()), 1)
if __name__ == '__main__':
import unittest
unittest.main()
......@@ -67,8 +67,7 @@ class ContainedSearchForRelatedEntitiesView(rwdg.SearchForRelatedEntitiesView):
rdef = entity.e_schema.rdef(rtype, role, tetype)
assert len(rdef.constraints) == 1 and 'S container AT' in rdef.constraints[0].expression
baserql = rdef.constraints[0].expression
baserql.replace('S container AT', 'AT eid %(at)s')
rql = 'Any O WHERE ' + baserql
rql = 'Any O WHERE ' + baserql.replace('S container AT', 'AT eid %(at)s')
return self._cw.execute(rql, {'at': int(self._cw.form['container'])})
......
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