Shorten tests
COUCHDB-2787
diff --git a/.travis.yml b/.travis.yml
index 04fdb33..2c6b2f0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,7 +9,7 @@
- cp -R ../src ./src/mango
- make
- cd ..
- - couchdb/dev/run -n 1 --with-admin-party-please &
+ - couchdb/dev/run -n 1 --admin=testuser:testpass &
- sleep 10
before_script:
diff --git a/Makefile b/Makefile
index 8c136c1..1b2a504 100644
--- a/Makefile
+++ b/Makefile
@@ -46,6 +46,7 @@
# target: pip-install - Installs requires Python packages
pip-install:
pip install nose requests
+ pip install hypothesis
.PHONY: venv
diff --git a/test/06-basic-text-test.py b/test/06-basic-text-test.py
index 53e9159..28c495a 100644
--- a/test/06-basic-text-test.py
+++ b/test/06-basic-text-test.py
@@ -14,9 +14,8 @@
import mango
import unittest
import user_docs
-import copy
-import num_string_docs
-from hypothesis import given, assume
+import math
+from hypothesis import given, assume, example
import hypothesis.strategies as st
@unittest.skipIf(mango.has_text_service(), "text service exists")
@@ -565,45 +564,24 @@
def setUpClass(klass):
super(NumStringTests, klass).setUpClass()
klass.db.recreate()
- klass.db.create_text_index()
+ if mango.has_text_service():
+ klass.db.create_text_index()
- def test_nan_val(self):
- doc = {"number_NaN": "NaN"}
- self.db.save_doc(doc)
- q = {"$text": "NaN"}
- docs = self.db.find(q)
- print docs
- assert docs[0]["number_NaN"] == "NaN"
+ # not available for python 2.7.x
+ def isFinite(num):
+ not (math.isinf(num) or math.isnan(num))
- def test_infinity_val(self):
- doc = {"number_Infinity": "Infinity"}
- self.db.save_doc(doc)
- q = {"$text": "Infinity"}
- docs = self.db.find(q)
- assert docs[0]["number_Infinity"] == "Infinity"
-
- @given(float_point_string=st.floats().map(str))
- def test_floating_point_val(self,float_point_string):
- assume(float_point_string!="nan")
- doc = {"number_string": float_point_string}
- self.db.save_doc(doc)
- q = {"$text": float_point_string}
- docs = self.db.find(q)
- if len(docs) == 1:
- assert docs[0]["number_string"] == float_point_string
- if len(docs) == 2:
- if docs[0]["number_string"] != float_point_string:
- assert docs[1]["number_string"] == float_point_string
-
- @given(f=st.floats())
+ @given(f=st.floats().filter(isFinite).map(str)
+ | st.floats().map(lambda f: f.hex()))
+ @example('NaN')
+ @example('Infinity')
def test_floating_point_val(self,f):
- hex_float_point_string = f.hex()
- doc = {"number_string": hex_float_point_string}
+ doc = {"number_string": f}
self.db.save_doc(doc)
- q = {"$text": hex_float_point_string}
+ q = {"$text": f}
docs = self.db.find(q)
if len(docs) == 1:
- assert docs[0]["number_string"] == hex_float_point_string
+ assert docs[0]["number_string"] == f
if len(docs) == 2:
- if docs[0]["number_string"] != hex_float_point_string:
- assert docs[1]["number_string"] == hex_float_point_string
+ if docs[0]["number_string"] != f:
+ assert docs[1]["number_string"] == f
diff --git a/test/mango.py b/test/mango.py
index 0487557..5ca8367 100644
--- a/test/mango.py
+++ b/test/mango.py
@@ -21,7 +21,6 @@
import friend_docs
import user_docs
import limit_docs
-import num_string_docs
def random_db_name():
@@ -242,11 +241,3 @@
super(LimitDocsTextTests, klass).setUpClass()
if has_text_service():
limit_docs.setup(klass.db, index_type="text")
-
-class NumStringDocsTextTests(DbPerClass):
-
- @classmethod
- def setUpClass(klass):
- super(NumStringDocsTextTests, klass).setUpClass()
- if has_text_service():
- num_string_docs.setup(klass.db, index_type="text")