本文整理汇总了Python中mock.call.insert_definition函数的典型用法代码示例。如果您正苦于以下问题:Python insert_definition函数的具体用法?Python insert_definition怎么用?Python insert_definition使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了insert_definition函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_write_multiple_definitions_on_close
def test_write_multiple_definitions_on_close(self):
self.conn.get_course_index.return_value = None
self.bulk._begin_bulk_operation(self.course_key)
self.conn.reset_mock()
self.bulk.update_definition(self.course_key.replace(branch='a'), self.definition)
other_definition = {'another': 'definition', '_id': ObjectId()}
self.bulk.update_definition(self.course_key.replace(branch='b'), other_definition)
self.assertConnCalls()
self.bulk._end_bulk_operation(self.course_key)
self.assertItemsEqual(
[call.insert_definition(self.definition), call.insert_definition(other_definition)],
self.conn.mock_calls
)
开发者ID:CDOT-EDX,项目名称:edx-platform,代码行数:13,代码来源:test_split_modulestore_bulk_operations.py
示例2: test_write_definition_on_close
def test_write_definition_on_close(self):
self.conn.get_course_index.return_value = None
self.bulk._begin_bulk_operation(self.course_key)
self.conn.reset_mock()
self.bulk.update_definition(self.course_key, self.definition)
self.assertConnCalls()
self.bulk._end_bulk_operation(self.course_key)
self.assertConnCalls(call.insert_definition(self.definition, self.course_key))
开发者ID:edx,项目名称:edx-platform,代码行数:8,代码来源:test_split_modulestore_bulk_operations.py
示例3: test_write_index_and_multiple_definitions_on_close
def test_write_index_and_multiple_definitions_on_close(self):
original_index = {'versions': {'a': ObjectId(), 'b': ObjectId()}}
self.conn.get_course_index.return_value = copy.deepcopy(original_index)
self.bulk._begin_bulk_operation(self.course_key)
self.conn.reset_mock()
self.bulk.update_definition(self.course_key.replace(branch='a'), self.definition)
other_definition = {'another': 'definition', '_id': ObjectId()}
self.bulk.update_definition(self.course_key.replace(branch='b'), other_definition)
self.bulk.insert_course_index(self.course_key, {'versions': {'a': self.definition['_id'], 'b': other_definition['_id']}})
self.bulk._end_bulk_operation(self.course_key)
self.assertItemsEqual(
[
call.insert_definition(self.definition),
call.insert_definition(other_definition),
call.update_course_index(
{'versions': {'a': self.definition['_id'], 'b': other_definition['_id']}},
from_index=original_index
)
],
self.conn.mock_calls
)
开发者ID:CDOT-EDX,项目名称:edx-platform,代码行数:21,代码来源:test_split_modulestore_bulk_operations.py
示例4: test_write_index_and_multiple_definitions_on_close
def test_write_index_and_multiple_definitions_on_close(self):
original_index = {"versions": {"a": ObjectId(), "b": ObjectId()}}
self.conn.get_course_index.return_value = copy.deepcopy(original_index)
self.bulk._begin_bulk_operation(self.course_key)
self.conn.reset_mock()
self.bulk.update_definition(self.course_key.replace(branch="a"), self.definition)
other_definition = {"another": "definition", "_id": ObjectId()}
self.bulk.update_definition(self.course_key.replace(branch="b"), other_definition)
self.bulk.insert_course_index(
self.course_key, {"versions": {"a": self.definition["_id"], "b": other_definition["_id"]}}
)
self.bulk._end_bulk_operation(self.course_key)
self.assertItemsEqual(
[
call.insert_definition(self.definition, self.course_key),
call.insert_definition(other_definition, self.course_key),
call.update_course_index(
{"versions": {"a": self.definition["_id"], "b": other_definition["_id"]}},
from_index=original_index,
course_context=self.course_key,
),
],
self.conn.mock_calls,
)
开发者ID:edx,项目名称:edx-platform,代码行数:24,代码来源:test_split_modulestore_bulk_operations.py
示例5: test_write_index_and_definition_on_close
def test_write_index_and_definition_on_close(self):
original_index = {'versions': {}}
self.conn.get_course_index.return_value = copy.deepcopy(original_index)
self.bulk._begin_bulk_operation(self.course_key)
self.conn.reset_mock()
self.bulk.update_definition(self.course_key, self.definition)
self.bulk.insert_course_index(self.course_key, {'versions': {self.course_key.branch: self.definition['_id']}})
self.assertConnCalls()
self.bulk._end_bulk_operation(self.course_key)
self.assertConnCalls(
call.insert_definition(self.definition),
call.update_course_index(
{'versions': {self.course_key.branch: self.definition['_id']}},
from_index=original_index
)
)
开发者ID:CDOT-EDX,项目名称:edx-platform,代码行数:16,代码来源:test_split_modulestore_bulk_operations.py
示例6: test_no_bulk_write_definition
def test_no_bulk_write_definition(self):
# Writing a definition when no bulk operation is active should just
# call through to the db_connection.
self.bulk.update_definition(self.course_key, self.definition)
self.assertConnCalls(call.insert_definition(self.definition, self.course_key))
开发者ID:edx,项目名称:edx-platform,代码行数:5,代码来源:test_split_modulestore_bulk_operations.py
注:本文中的mock.call.insert_definition函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论