[test] use FakeFile instead of File in test_fulltextindex
File.data is no longer fulltextindexed.
--- 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
--- 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 <http://www.gnu.org/licenses/>.
-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')
--- 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 <http://www.gnu.org/licenses/>.
-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')
--- 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 @@
<span style="color: #C00000;">lambda</span> <span style="color: #000000;">x</span><span style="color: #0000C0;">:</span> <span style="color: #0080C0;">1</span>
</pre>''')
- 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'<p><em>héhéhé</em></p>')
@@ -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 <em>html</em>'
e.cw_attr_cache['description_format'] = 'text/html'
e.cw_attr_cache['data'] = Binary('some <em>data</em>')
--- 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):
--- 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'),