# HG changeset patch
# User Samuel Trégouët <samuel.tregouet@logilab.fr>
# Date 1466000252 -7200
#      Wed Jun 15 16:17:32 2016 +0200
# Node ID afd8a876c64c05c4a55b8b9da04adc46e2329f5f
# Parent  6527f18a1a6997c9893aafb2beb58ad38f0b2d18
test: fulltext_indexable_rql

diff --git a/test/data/schema.py b/test/data/schema.py
new file mode 100644
--- /dev/null
+++ b/test/data/schema.py
@@ -0,0 +1,8 @@
+from yams.buildobjs import (EntityType, String, Int,
+                            SubjectRelation, RelationDefinition)
+
+
+class Person(EntityType):
+    name = String()
+    age = Int()
+
diff --git a/test/test_elastic_search.py b/test/test_elastic_search.py
--- a/test/test_elastic_search.py
+++ b/test/test_elastic_search.py
@@ -13,7 +13,8 @@
 from cubicweb.devtools import testlib
 from cubicweb.cwconfig import CubicWebConfiguration
 from cubes.elasticsearch import ccplugin
-from cubes.elasticsearch.es import indexable_types, INDEX_SETTINGS
+from cubes.elasticsearch.es import (indexable_types, INDEX_SETTINGS,
+                                    fulltext_indexable_rql)
 
 # TODO - find a way to configure ElasticSearch as non threaded while running tests
 # so that the traces show the full stack, not just starting from connection.http_*
@@ -157,7 +158,7 @@
         with self.new_access('anon').web_request() as req:
             # self._cw.form.get('search'))
             self.view('esearch', req=req, template=None)
-    
+
     @patch('elasticsearch_dsl.search.Search.execute', new=mock_execute_150)
     @patch('elasticsearch_dsl.connections.connections.get_connection', new=mock_cnx)
     def skip_test_search_view_150(self):
@@ -166,5 +167,17 @@
             self.view('esearch', req=req, template=None)
 
 
+class ElasticsearchTC(testlib.CubicWebTC):
+
+    def test_1(self):
+        with self.admin_access.cnx() as cnx:
+            print (cnx.vreg.schema)
+            schema = cnx.vreg.schema
+            etype = 'Person'
+            rql = fulltext_indexable_rql(etype, schema)
+            self.assertIn('age', rql)
+            self.assertNotIn('eid', rql)
+
+
 if __name__ == '__main__':
     unittest.main()