コード例 #1
0
 def test_fetch_no_views(self):
     """
     Ensure that the document fetched from the database returns the
     DesignDocument format as expected when retrieving a design document
     containing no views.
     """
     ddoc = DesignDocument(self.db, "_design/ddoc001")
     ddoc.save()
     ddoc_remote = DesignDocument(self.db, "_design/ddoc001")
     ddoc_remote.fetch()
     self.assertEqual(set(ddoc_remote.keys()), {"_id", "_rev", "views"})
     self.assertEqual(ddoc_remote["_id"], "_design/ddoc001")
     self.assertTrue(ddoc_remote["_rev"].startswith("1-"))
     self.assertEqual(ddoc_remote["_rev"], ddoc["_rev"])
     self.assertEqual(ddoc_remote.views, {})
コード例 #2
0
 def test_fetch_no_views(self):
     """
     Ensure that the document fetched from the database returns the
     DesignDocument format as expected when retrieving a design document
     containing no views.
     """
     ddoc = DesignDocument(self.db, '_design/ddoc001')
     ddoc.save()
     ddoc_remote = DesignDocument(self.db, '_design/ddoc001')
     ddoc_remote.fetch()
     self.assertEqual(set(ddoc_remote.keys()),
                      {'_id', '_rev', 'indexes', 'views'})
     self.assertEqual(ddoc_remote['_id'], '_design/ddoc001')
     self.assertTrue(ddoc_remote['_rev'].startswith('1-'))
     self.assertEqual(ddoc_remote['_rev'], ddoc['_rev'])
     self.assertEqual(ddoc_remote.views, {})
コード例 #3
0
 def test_fetch_no_search_index(self):
     """
     Ensure that the document fetched from the database returns the
     DesignDocument format as expected when retrieving a design document
     containing no search indexes.
     The :func:`~cloudant.design_document.DesignDocument.fetch` function
     adds the ``indexes`` key in the locally cached DesignDocument if
     indexes do not exist in the remote design document.
     """
     ddoc = DesignDocument(self.db, '_design/ddoc001')
     ddoc.save()
     ddoc_remote = DesignDocument(self.db, '_design/ddoc001')
     ddoc_remote.fetch()
     self.assertEqual(set(ddoc_remote.keys()),
                      {'_id', '_rev', 'indexes', 'views'})
     self.assertEqual(ddoc_remote['_id'], '_design/ddoc001')
     self.assertTrue(ddoc_remote['_rev'].startswith('1-'))
     self.assertEqual(ddoc_remote['_rev'], ddoc['_rev'])
     self.assertEqual(ddoc_remote.indexes, {})
コード例 #4
0
 def test_save_with_no_search_indexes(self):
     """
     Tests the functionality when saving a design document without a search
     index. Both the locally cached and remote DesignDocument should not
     include the empty indexes sub-document.
     """
     ddoc = DesignDocument(self.db, '_design/ddoc001')
     ddoc.save()
     # Ensure that locally cached DesignDocument contains an
     # empty search indexes and views dict.
     self.assertEqual(set(ddoc.keys()), {'_id', '_rev', 'indexes', 'views'})
     self.assertEqual(ddoc['_id'], '_design/ddoc001')
     self.assertTrue(ddoc['_rev'].startswith('1-'))
     # Ensure that remotely saved design document does not
     # include a search indexes sub-document.
     resp = self.client.r_session.get(ddoc.document_url)
     raw_ddoc = resp.json()
     self.assertEqual(set(raw_ddoc.keys()), {'_id', '_rev'})
     self.assertEqual(raw_ddoc['_id'], ddoc['_id'])
     self.assertEqual(raw_ddoc['_rev'], ddoc['_rev'])
コード例 #5
0
 def test_save_with_no_views(self):
     """
     Tests the functionality when saving a design document without a view.
     The locally cached DesignDocument should contain an empty views dict
     while the design document saved remotely should not include the empty
     views sub-document.
     """
     ddoc = DesignDocument(self.db, "_design/ddoc001")
     ddoc.save()
     # Ensure that locally cached DesignDocument contains an
     # empty views dict.
     self.assertEqual(set(ddoc.keys()), {"_id", "_rev", "views"})
     self.assertEqual(ddoc["_id"], "_design/ddoc001")
     self.assertTrue(ddoc["_rev"].startswith("1-"))
     self.assertEqual(ddoc.views, {})
     # Ensure that remotely saved design document does not
     # include a views sub-document.
     resp = self.client.r_session.get(ddoc.document_url)
     raw_ddoc = resp.json()
     self.assertEqual(set(raw_ddoc.keys()), {"_id", "_rev"})
     self.assertEqual(raw_ddoc["_id"], ddoc["_id"])
     self.assertEqual(raw_ddoc["_rev"], ddoc["_rev"])