Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 087bbc3

Browse files
committed
Refactored test_index_usage_via_query
Changed to assert that a warning is returned with the result rather than expecting an exception.
1 parent 2fb19d7 commit 087bbc3

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

tests/unit/index_tests.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,20 +351,15 @@ def test_index_via_query(self):
351351

352352
def test_index_usage_via_query(self):
353353
"""
354-
Test that a query will fail if the indexes that exist do not satisfy the
354+
Test that a query will warn if the indexes that exist do not satisfy the
355355
query selector.
356356
"""
357357
index = Index(self.db, 'ddoc001', 'index001', fields=['name'])
358358
index.create()
359359
self.populate_db_with_documents(100)
360-
query = Query(self.db)
361-
with self.assertRaises(requests.HTTPError) as cm:
362-
resp = query(
363-
fields=['name', 'age'],
364-
selector={'age': {'$eq': 6}}
365-
)
366-
err = cm.exception
367-
self.assertEqual(err.response.status_code, 400)
360+
result = self.db.get_query_result(fields=['name', 'age'],
361+
selector={'age': {'$eq': 6}}, raw_result=True)
362+
self.assertTrue(str(result['warning']).startswith("no matching index found"))
368363

369364
@unittest.skipUnless(
370365
os.environ.get('RUN_CLOUDANT_TESTS') is not None,

0 commit comments

Comments
 (0)