test Bytes storage/retreival stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 27 May 2009 11:17:53 +0200
branchstable
changeset 1949 9064102b4deb
parent 1948 887ed691c635
child 1950 ab7a41b2cd26
test Bytes storage/retreival
server/test/unittest_querier.py
--- a/server/test/unittest_querier.py	Tue May 26 19:46:08 2009 +0200
+++ b/server/test/unittest_querier.py	Wed May 27 11:17:53 2009 +0200
@@ -6,7 +6,7 @@
 from logilab.common.testlib import TestCase, unittest_main
 from rql import BadRQLQuery, RQLSyntaxError
 
-from cubicweb import QueryError, Unauthorized
+from cubicweb import QueryError, Unauthorized, Binary
 from cubicweb.server.sqlutils import SQL_PREFIX
 from cubicweb.server.utils import crypt_password
 from cubicweb.server.sources.native import make_schema
@@ -208,6 +208,13 @@
         # should return an empty result set
         self.failIf(self.execute('Any X WHERE X eid 99999999'))
 
+    def test_bytes_storage(self):
+        feid = self.execute('INSERT File X: X name "foo.pdf", X data_format "text/plain", X data %(data)s',
+                            {'data': Binary("xxx")})[0][0]
+        fdata = self.execute('Any D WHERE X data D, X eid %(x)s', {'x': feid}, 'x')[0][0]
+        self.assertIsInstance(fdata, Binary)
+        self.assertEquals(fdata.getvalue(), 'xxx')
+
     # selection queries tests #################################################
 
     def test_select_1(self):