lanto03 / couchdb-python

Automatically exported from code.google.com/p/couchdb-python
Other
0 stars 0 forks source link

The test suite shouldn't assume the Python view server is installed #67

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Currently, test_view_function_objects fails when the Python view server
isn't installed. I don't think this is the right behavior. Current patch
solves this by checking the config for installed query servers and not
running the test if no view server called 'python' is installed.

diff --git a/couchdb/tests/client.py b/couchdb/tests/client.py
--- a/couchdb/tests/client.py
+++ b/couchdb/tests/client.py
@@ -155,6 +155,10 @@
             self.assertEqual(i, res[idx].key)

     def test_view_function_objects(self):
+        resp, config = self.server.resource.get('/_config')
+        if 'python' not in config['query_servers']:
+            return
+
         for i in range(1, 4):
             self.db.create({'i': i, 'j':2*i})

Original issue reported on code.google.com by djc.ochtman on 19 Mar 2009 at 1:39

GoogleCodeExporter commented 8 years ago
Actually, this would be even nicer. Add API to get to the config:

diff --git a/couchdb/client.py b/couchdb/client.py
--- a/couchdb/client.py
+++ b/couchdb/client.py
@@ -177,6 +177,17 @@
         :type: `unicode`
         """)

+    def _get_config(self):
+        resp, data = self.resource.get('/_config')
+        return data
+    config = property(_get_config, doc="""\
+        The configuration data for the CouchDB server.
+
+        Requests an object with basic configuration data from the server.
+
+        :type: `dict`
+        """)
+
     def create(self, name):
         """Create a new database with the given name.

diff --git a/couchdb/tests/client.py b/couchdb/tests/client.py
--- a/couchdb/tests/client.py
+++ b/couchdb/tests/client.py
@@ -27,6 +27,10 @@
         if 'python-tests' in self.server:
             del self.server['python-tests']

+    def test_server_vars(self):
+        version = self.server.version
+        config = self.server.config
+
     def test_create_large_doc(self):
         self.db['foo'] = {'data': '0123456789' * 110 * 1024} # 10 MB
         self.assertEqual('foo', self.db['foo']['_id'])

Then the above patch becomes even smaller:

diff --git a/couchdb/tests/client.py b/couchdb/tests/client.py
--- a/couchdb/tests/client.py
+++ b/couchdb/tests/client.py
@@ -159,6 +159,9 @@
             self.assertEqual(i, res[idx].key)

     def test_view_function_objects(self):
+        if 'python' not in self.server.config['query_servers']:
+            return
+
         for i in range(1, 4):
             self.db.create({'i': i, 'j':2*i})

Original comment by djc.ochtman on 19 Mar 2009 at 2:47

GoogleCodeExporter commented 8 years ago
Applied in r142. Thanks and sorry for the long wait!

Original comment by cmlenz on 15 Apr 2009 at 4:23