# HG changeset patch # User Julien Cristau # Date 1436433969 -7200 # Node ID 747eded13c684edac617b1e5b8a4941988be50d0 # Parent 992a54e0df41f5e9a5094233f8749fb9ab71cb6e [test] use FakeFile instead of File in test_fulltextindex File.data is no longer fulltextindexed. diff -r 992a54e0df41 -r 747eded13c68 test/data/bootstrap_cubes --- a/test/data/bootstrap_cubes Thu Jul 09 16:55:28 2015 +0200 +++ b/test/data/bootstrap_cubes Thu Jul 09 11:26:09 2015 +0200 @@ -1,1 +1,1 @@ -card, file, tag, localperms +card, tag, localperms diff -r 992a54e0df41 -r 747eded13c68 test/data/entities.py --- a/test/data/entities.py Thu Jul 09 16:55:28 2015 +0200 +++ b/test/data/entities.py Thu Jul 09 11:26:09 2015 +0200 @@ -16,7 +16,9 @@ # You should have received a copy of the GNU Lesser General Public License along # with CubicWeb. If not, see . -from cubicweb.entities import AnyEntity, fetch_config +from cubicweb.entities import AnyEntity, fetch_config, adapters +from cubicweb.predicates import is_instance + class Societe(AnyEntity): __regid__ = 'Societe' @@ -34,3 +36,7 @@ class Note(AnyEntity): __regid__ = 'Note' + + +class FakeFileIDownloadableAdapter(adapters.IDownloadableAdapter): + __select__ = is_instance('FakeFile') diff -r 992a54e0df41 -r 747eded13c68 test/data/schema.py --- a/test/data/schema.py Thu Jul 09 16:55:28 2015 +0200 +++ b/test/data/schema.py Thu Jul 09 11:26:09 2015 +0200 @@ -16,13 +16,16 @@ # You should have received a copy of the GNU Lesser General Public License along # with CubicWeb. If not, see . -from yams.buildobjs import (EntityType, String, SubjectRelation, - RelationDefinition) +from yams.buildobjs import (EntityType, String, RichString, Bytes, + SubjectRelation, RelationDefinition) from cubicweb.schema import (WorkflowableEntityType, RQLConstraint, RQLVocabularyConstraint) +_ = unicode + + class Personne(EntityType): nom = String(required=True) prenom = String() @@ -94,3 +97,17 @@ class Reference(EntityType): nom = String(unique=True) ean = String(unique=True, required=True) + + +class FakeFile(EntityType): + title = String(fulltextindexed=True, maxsize=256) + data = Bytes(required=True, fulltextindexed=True, description=_('file to upload')) + data_format = String(required=True, maxsize=128, + description=_('MIME type of the file. Should be dynamically set at upload time.')) + data_encoding = String(maxsize=32, + description=_('encoding of the file when it applies (e.g. text). ' + 'Should be dynamically set at upload time.')) + data_name = String(required=True, fulltextindexed=True, + description=_('name of the file. Should be dynamically set at upload time.')) + description = RichString(fulltextindexed=True, internationalizable=True, + default_format='text/rest') diff -r 992a54e0df41 -r 747eded13c68 test/unittest_entity.py --- a/test/unittest_entity.py Thu Jul 09 16:55:28 2015 +0200 +++ b/test/unittest_entity.py Thu Jul 09 11:26:09 2015 +0200 @@ -644,7 +644,7 @@ def test_printable_value_bytes(self): with self.admin_access.web_request() as req: - e = req.create_entity('File', data=Binary('lambda x: 1'), data_format=u'text/x-python', + e = req.create_entity('FakeFile', data=Binary('lambda x: 1'), data_format=u'text/x-python', data_encoding=u'ascii', data_name=u'toto.py') from cubicweb import mttransforms if mttransforms.HAS_PYGMENTS_TRANSFORMS: @@ -663,7 +663,7 @@ lambda x: 1 ''') - e = req.create_entity('File', data=Binary('*héhéhé*'), data_format=u'text/rest', + e = req.create_entity('FakeFile', data=Binary('*héhéhé*'), data_format=u'text/rest', data_encoding=u'utf-8', data_name=u'toto.txt') self.assertEqual(e.printable_value('data'), u'

héhéhé

') @@ -714,7 +714,7 @@ def test_fulltextindex(self): with self.admin_access.web_request() as req: - e = self.vreg['etypes'].etype_class('File')(req) + e = self.vreg['etypes'].etype_class('FakeFile')(req) e.cw_attr_cache['description'] = 'du html' e.cw_attr_cache['description_format'] = 'text/html' e.cw_attr_cache['data'] = Binary('some data') diff -r 992a54e0df41 -r 747eded13c68 test/unittest_predicates.py --- a/test/unittest_predicates.py Thu Jul 09 16:55:28 2015 +0200 +++ b/test/unittest_predicates.py Thu Jul 09 11:26:09 2015 +0200 @@ -37,12 +37,13 @@ class ImplementsTC(CubicWebTC): def test_etype_priority(self): with self.admin_access.web_request() as req: - f = req.create_entity('File', data_name=u'hop.txt', data=Binary('hop')) + f = req.create_entity('FakeFile', data_name=u'hop.txt', data=Binary('hop'), + data_format=u'text/plain') rset = f.as_rset() anyscore = is_instance('Any')(f.__class__, req, rset=rset) idownscore = adaptable('IDownloadable')(f.__class__, req, rset=rset) self.assertTrue(idownscore > anyscore, (idownscore, anyscore)) - filescore = is_instance('File')(f.__class__, req, rset=rset) + filescore = is_instance('FakeFile')(f.__class__, req, rset=rset) self.assertTrue(filescore > idownscore, (filescore, idownscore)) def test_etype_inheritance_no_yams_inheritance(self): diff -r 992a54e0df41 -r 747eded13c68 test/unittest_schema.py --- a/test/unittest_schema.py Thu Jul 09 16:55:28 2015 +0200 +++ b/test/unittest_schema.py Thu Jul 09 11:26:09 2015 +0200 @@ -169,7 +169,7 @@ 'CWRelation', 'CWPermission', 'CWProperty', 'CWRType', 'CWSource', 'CWSourceHostConfig', 'CWSourceSchemaConfig', 'CWUniqueTogetherConstraint', 'CWUser', - 'ExternalUri', 'File', 'Float', 'Int', 'Interval', 'Note', + 'ExternalUri', 'FakeFile', 'Float', 'Int', 'Interval', 'Note', 'Password', 'Personne', 'Produit', 'RQLExpression', 'Reference', 'Service', 'Societe', 'State', 'StateFull', 'String', 'SubNote', 'SubWorkflowExitPoint', @@ -221,8 +221,6 @@ 'value', 'wf_info_for', 'wikiid', 'workflow_of', 'tr_count'] - if config.cube_version('file') >= (1, 14, 0): - expected_relations.append('data_sha1hex') self.assertListEqual(sorted(expected_relations), relations) @@ -510,7 +508,7 @@ ('cw_source', 'Card', 'CWSource', 'object'), ('cw_source', 'EmailAddress', 'CWSource', 'object'), ('cw_source', 'ExternalUri', 'CWSource', 'object'), - ('cw_source', 'File', 'CWSource', 'object'), + ('cw_source', 'FakeFile', 'CWSource', 'object'), ('cw_source', 'Note', 'CWSource', 'object'), ('cw_source', 'Personne', 'CWSource', 'object'), ('cw_source', 'Produit', 'CWSource', 'object'),