当前位置: 首页>>代码示例>>Python>>正文


Python DesignDocument.get方法代码示例

本文整理汇总了Python中cloudant.design_document.DesignDocument.get方法的典型用法代码示例。如果您正苦于以下问题:Python DesignDocument.get方法的具体用法?Python DesignDocument.get怎么用?Python DesignDocument.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cloudant.design_document.DesignDocument的用法示例。


在下文中一共展示了DesignDocument.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_update_a_search_index_with_analyzer

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_update_a_search_index_with_analyzer(self):
     """
     Test that updating a search analyzer updates the contents of the correct
     search index object in the DesignDocument dictionary.
     """
     ddoc = DesignDocument(self.db, '_design/ddoc001')
     ddoc.add_search_index('search001',
                           'not-a-valid-search-index',
                           'email')
     self.assertEqual(
         ddoc.get('indexes')['search001'],
         {'index': 'not-a-valid-search-index', 'analyzer': 'email'}
     )
     ddoc.update_search_index(
         'search001',
         'function (doc) {\n  index("default", doc._id); '
         'if (doc._id) {index("name", doc.name, {"store": true}); }\n}',
         'simple'
     )
     self.assertEqual(
         ddoc.get('indexes')['search001'],
         {'index': 'function (doc) {\n  index("default", doc._id); '
             'if (doc._id) {index("name", doc.name, '
             '{"store": true}); }\n}',
          'analyzer': 'simple'
         }
     )
开发者ID:drarvindsathi,项目名称:python-cloudant,代码行数:29,代码来源:design_document_tests.py

示例2: test_constructor_without_docid

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_constructor_without_docid(self):
     """
     Test instantiating a DesignDocument without providing an id
     """
     ddoc = DesignDocument(self.db)
     self.assertIsInstance(ddoc, DesignDocument)
     self.assertIsNone(ddoc.get("_id"))
     self.assertEqual(ddoc.get("views"), {})
开发者ID:rredburn,项目名称:python-cloudant,代码行数:10,代码来源:design_document_tests.py

示例3: test_constructor_with_design_docid

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_constructor_with_design_docid(self):
     """
     Test instantiating a DesignDocument providing an id
     prefaced with '_design/'
     """
     ddoc = DesignDocument(self.db, "_design/ddoc001")
     self.assertIsInstance(ddoc, DesignDocument)
     self.assertEqual(ddoc.get("_id"), "_design/ddoc001")
     self.assertEqual(ddoc.get("views"), {})
开发者ID:rredburn,项目名称:python-cloudant,代码行数:11,代码来源:design_document_tests.py

示例4: test_delete_a_view

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_delete_a_view(self):
     """
     Test deleting a view from the DesignDocument dictionary.
     """
     ddoc = DesignDocument(self.db, "_design/ddoc001")
     ddoc.add_view("view001", "function (doc) {\n  emit(doc._id, 1);\n}")
     self.assertEqual(ddoc.get("views")["view001"], {"map": "function (doc) {\n  emit(doc._id, 1);\n}"})
     ddoc.delete_view("view001")
     self.assertEqual(ddoc.get("views"), {})
开发者ID:rredburn,项目名称:python-cloudant,代码行数:11,代码来源:design_document_tests.py

示例5: test_constructor_with_docid

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_constructor_with_docid(self):
     """
     Test instantiating a DesignDocument providing an id
     not prefaced with '_design/'
     """
     ddoc = DesignDocument(self.db, 'ddoc001')
     self.assertIsInstance(ddoc, DesignDocument)
     self.assertEqual(ddoc.get('_id'), '_design/ddoc001')
     self.assertEqual(ddoc.get('views'), {})
开发者ID:JanekLehr,项目名称:python-cloudant,代码行数:11,代码来源:design_document_tests.py

示例6: test_create_design_document_with_docid_encoded_url

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_create_design_document_with_docid_encoded_url(self):
     """
     Test creating a design document providing an id that has an encoded url
     """
     ddoc = DesignDocument(self.db, "_design/http://example.com")
     self.assertFalse(ddoc.exists())
     self.assertIsNone(ddoc.get("_rev"))
     ddoc.create()
     self.assertTrue(ddoc.exists())
     self.assertTrue(ddoc.get("_rev").startswith("1-"))
开发者ID:rredburn,项目名称:python-cloudant,代码行数:12,代码来源:design_document_tests.py

示例7: test_update_a_view

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_update_a_view(self):
     """
     Test that updating a view updates the contents of the correct
     View object in the DesignDocument dictionary.
     """
     ddoc = DesignDocument(self.db, "_design/ddoc001")
     ddoc.add_view("view001", "not-a-valid-map-function")
     self.assertEqual(ddoc.get("views")["view001"], {"map": "not-a-valid-map-function"})
     ddoc.update_view("view001", "function (doc) {\n  emit(doc._id, 1);\n}")
     self.assertEqual(ddoc.get("views")["view001"], {"map": "function (doc) {\n  emit(doc._id, 1);\n}"})
开发者ID:rredburn,项目名称:python-cloudant,代码行数:12,代码来源:design_document_tests.py

示例8: test_add_a_view

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_add_a_view(self):
     """
     Test that adding a view adds a View object to
     the DesignDocument dictionary.
     """
     ddoc = DesignDocument(self.db, "_design/ddoc001")
     self.assertEqual(ddoc.get("views"), {})
     ddoc.add_view("view001", "function (doc) {\n  emit(doc._id, 1);\n}")
     self.assertListEqual(list(ddoc.get("views").keys()), ["view001"])
     self.assertIsInstance(ddoc.get("views")["view001"], View)
     self.assertEqual(ddoc.get("views")["view001"], {"map": "function (doc) {\n  emit(doc._id, 1);\n}"})
开发者ID:rredburn,项目名称:python-cloudant,代码行数:13,代码来源:design_document_tests.py

示例9: test_delete_a_view

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_delete_a_view(self):
     """
     Test deleting a view from the DesignDocument dictionary.
     """
     ddoc = DesignDocument(self.db, '_design/ddoc001')
     ddoc.add_view('view001', 'function (doc) {\n  emit(doc._id, 1);\n}')
     self.assertEqual(
         ddoc.get('views')['view001'],
         {'map': 'function (doc) {\n  emit(doc._id, 1);\n}'}
     )
     ddoc.delete_view('view001')
     self.assertEqual(ddoc.get('views'), {})
开发者ID:JanekLehr,项目名称:python-cloudant,代码行数:14,代码来源:design_document_tests.py

示例10: test_add_a_view

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_add_a_view(self):
     """
     Test that adding a view adds a View object to
     the DesignDocument dictionary.
     """
     ddoc = DesignDocument(self.db, '_design/ddoc001')
     self.assertEqual(ddoc.get('views'), {})
     ddoc.add_view(
         'view001',
         'function (doc) {\n  emit(doc._id, 1);\n}'
     )
     self.assertEqual(ddoc.get('views').keys(), ['view001'])
     self.assertIsInstance(ddoc.get('views')['view001'], View)
     self.assertEqual(
         ddoc.get('views')['view001'],
         {'map': 'function (doc) {\n  emit(doc._id, 1);\n}'}
     )
开发者ID:JanekLehr,项目名称:python-cloudant,代码行数:19,代码来源:design_document_tests.py

示例11: test_add_a_search_index

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_add_a_search_index(self):
     """
     Test that adding a search index adds a search index object to
     the DesignDocument dictionary.
     """
     ddoc = DesignDocument(self.db, '_design/ddoc001')
     self.assertEqual(ddoc.get('indexes'), {})
     ddoc.add_search_index(
         'search001',
         'function (doc) {\n  index("default", doc._id); '
         'if (doc._id) {index("name", doc.name, {"store": true}); }\n}'
     )
     self.assertListEqual(list(ddoc.get('indexes').keys()), ['search001'])
     self.assertEqual(
         ddoc.get('indexes')['search001'],
         {'index': 'function (doc) {\n  index("default", doc._id); '
             'if (doc._id) {index("name", doc.name, {"store": true}); }\n}'}
      )
开发者ID:drarvindsathi,项目名称:python-cloudant,代码行数:20,代码来源:design_document_tests.py

示例12: test_update_a_view

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_update_a_view(self):
     """
     Test that updating a view updates the contents of the correct
     View object in the DesignDocument dictionary.
     """
     ddoc = DesignDocument(self.db, '_design/ddoc001')
     ddoc.add_view('view001', 'not-a-valid-map-function')
     self.assertEqual(
         ddoc.get('views')['view001'],
         {'map': 'not-a-valid-map-function'}
     )
     ddoc.update_view(
         'view001',
         'function (doc) {\n  emit(doc._id, 1);\n}'
     )
     self.assertEqual(
         ddoc.get('views')['view001'],
         {'map': 'function (doc) {\n  emit(doc._id, 1);\n}'}
     )
开发者ID:JanekLehr,项目名称:python-cloudant,代码行数:21,代码来源:design_document_tests.py

示例13: test_delete_a_search_index

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_delete_a_search_index(self):
     """
     Test deleting a search index from the DesignDocument dictionary.
     """
     ddoc = DesignDocument(self.db, '_design/ddoc001')
     ddoc.add_search_index(
         'search001',
         'function (doc) {\n  index("default", doc._id); '
         'if (doc._id) {index("name", doc.name, '
         '{"store": true}); }\n}'
     )
     self.assertEqual(
         ddoc.get('indexes')['search001'],
         {'index': 'function (doc) {\n  index("default", doc._id); '
             'if (doc._id) {index("name", doc.name, '
             '{"store": true}); }\n}'}
     )
     ddoc.delete_index('search001')
     self.assertEqual(ddoc.get('indexes'), {})
开发者ID:drarvindsathi,项目名称:python-cloudant,代码行数:21,代码来源:design_document_tests.py

示例14: test_setting_id

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_setting_id(self):
     """
     Ensure when setting the design document id that it is
     prefaced by '_design/'
     """
     ddoc = DesignDocument(self.db)
     ddoc["_id"] = "ddoc001"
     self.assertEqual(ddoc["_id"], "_design/ddoc001")
     del ddoc["_id"]
     self.assertIsNone(ddoc.get("_id"))
     ddoc["_id"] = "_design/ddoc002"
     self.assertEqual(ddoc["_id"], "_design/ddoc002")
开发者ID:rredburn,项目名称:python-cloudant,代码行数:14,代码来源:design_document_tests.py

示例15: test_add_a_search_index_with_analyzer

# 需要导入模块: from cloudant.design_document import DesignDocument [as 别名]
# 或者: from cloudant.design_document.DesignDocument import get [as 别名]
 def test_add_a_search_index_with_analyzer(self):
     """
     Test that adding a search index with an analyzer adds a search index
     object to the DesignDocument dictionary.
     """
     ddoc = DesignDocument(self.db, '_design/ddoc001')
     self.assertEqual(ddoc.get('indexes'), {})
     ddoc.add_search_index(
         'search001',
         'function (doc) {\n  index("default", doc._id); '
         'if (doc._id) {index("name", doc.name, {"store": true}); }\n}',
         {'name': 'perfield', 'default': 'english', 'fields': {
             'spanish': 'spanish'}}
     )
     self.assertListEqual(list(ddoc.get('indexes').keys()), ['search001'])
     self.assertEqual(
         ddoc.get('indexes')['search001'],
         {'index': 'function (doc) {\n  index("default", doc._id); '
             'if (doc._id) {index("name", doc.name, {"store": true}); }\n}',
             'analyzer': {"name": "perfield", "default": "english", "fields":
                 {"spanish": "spanish"}}}
      )
开发者ID:drarvindsathi,项目名称:python-cloudant,代码行数:24,代码来源:design_document_tests.py


注:本文中的cloudant.design_document.DesignDocument.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。