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

Commit 12ce1ef

Browse files
committed
Fixed design document tests for Cloudant
test_get_info: Removed Cloudant/Couch 2 fields from comparison. Removed Cloudant design doc name change that is not needed. test_geospatial_index: Removed rev field from row result before comparison.
1 parent 58c20dc commit 12ce1ef

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

tests/unit/design_document_tests.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -694,21 +694,26 @@ def test_get_info(self):
694694
ddoc_remote = DesignDocument(self.db, '_design/ddoc001')
695695
ddoc_remote.fetch()
696696
info = ddoc_remote.info()
697+
# Remove variable fields to make equality easier to check
697698
info['view_index'].pop('signature')
698699
info['view_index'].pop('disk_size')
699-
# Remove Cloudant specific sizes object
700+
# Remove Cloudant/Couch 2 fields if present to allow test to pass on Couch 1.6
700701
if 'sizes' in info['view_index']:
701702
info['view_index'].pop('sizes')
702-
name = ddoc_remote['_id']
703-
else:
704-
name = 'ddoc001'
703+
if 'updates_pending' in info['view_index']:
704+
info['view_index'].pop('updates_pending')
705+
706+
name = 'ddoc001'
705707
self.assertEqual(
706708
info,
707709
{'view_index': {'update_seq': 0, 'waiting_clients': 0,
708710
'language': 'javascript',
709711
'purge_seq': 0, 'compact_running': False,
710712
'waiting_commit': False, 'updater_running': False,
711-
'data_size': 0}, 'name': name})
713+
'data_size': 0
714+
},
715+
'name': name
716+
})
712717

713718
@unittest.skipUnless(
714719
os.environ.get('RUN_CLOUDANT_TESTS') is not None,
@@ -1405,13 +1410,17 @@ def test_geospatial_index(self):
14051410
'geoidx?g=point(-71.1%2042.3)'])).json()
14061411
self.assertIsNotNone(geo_result['bookmark'])
14071412
geo_result.pop('bookmark')
1408-
self.assertEqual(geo_result,
1409-
{'rows': [
1413+
rows = geo_result.pop('rows')
1414+
self.assertEqual(1, len(rows), "There should be 1 row.")
1415+
row = rows[0]
1416+
# Remove the rev before comparison
1417+
row.pop('rev')
1418+
self.assertEqual(row,
1419+
14101420
{'id': 'doc001',
14111421
'geometry':
14121422
{'type': 'Point',
1413-
'coordinates': [-71.1, 42.3]}}]
1414-
})
1423+
'coordinates': [-71.1, 42.3]}})
14151424

14161425
def test_add_a_show_function(self):
14171426
"""

0 commit comments

Comments
 (0)