本文整理汇总了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'
}
)
示例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"), {})
示例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"), {})
示例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"), {})
示例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'), {})
示例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-"))
示例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}"})
示例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}"})
示例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'), {})
示例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}'}
)
示例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}'}
)
示例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}'}
)
示例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'), {})
示例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")
示例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"}}}
)