本文整理汇总了Python中unittest.mock.Mock.all方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.all方法的具体用法?Python Mock.all怎么用?Python Mock.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.mock.Mock
的用法示例。
在下文中一共展示了Mock.all方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_query_mock
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import all [as 别名]
def create_query_mock(some_class):
query_mock = Mock()
query_mock.filter_by = Mock(side_effect=filter_by_mock_concept)
if some_class == LabelType:
query_mock.all = Mock(side_effect=list_all_types)
if some_class == Language:
query_mock.all = Mock(side_effect=list_all_languages)
return query_mock
示例2: create_query_mock
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import all [as 别名]
def create_query_mock(some_class):
query_mock = Mock()
if some_class in [Concept, Collection, Thing]:
query_mock.filter_by = Mock(side_effect=filter_by_mock_concept)
elif some_class == Language:
query_mock.filter_by = Mock(side_effect=filter_by_mock_language)
if some_class == LabelType:
query_mock.all = Mock(side_effect=list_all_types)
if some_class == Language:
query_mock.all = Mock(side_effect=list_all_languages)
return query_mock
示例3: filter_by_mock_concept
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import all [as 别名]
def filter_by_mock_concept(**kwargs):
filter_mock = Mock()
concept_id = None
conceptscheme_id = None
if 'concept_id' in kwargs:
concept_id = kwargs['concept_id']
if 'conceptscheme_id' in kwargs:
conceptscheme_id = kwargs['conceptscheme_id']
if concept_id == '1':
c = Concept(concept_id=concept_id, conceptscheme_id=conceptscheme_id)
c.type = 'concept'
filter_mock.one = Mock(return_value=c)
elif concept_id == '3':
c = Collection(concept_id=concept_id, conceptscheme_id=conceptscheme_id)
c.type = 'collection'
filter_mock.one = Mock(return_value=c)
elif concept_id == '555':
c = Thing(concept_id=concept_id, conceptscheme_id=conceptscheme_id)
filter_mock.one = Mock(return_value=c)
elif concept_id == '666':
raise NoResultFound
a_concept = Concept(concept_id=7895, conceptscheme_id=conceptscheme_id, type='concept')
a_labels = [Label(label='De Paardekastanje', language_id='nl'), Label(label='The Chestnut', language_id='en'),
Label(label='la châtaigne', language_id='fr')]
a_concept.labels = a_labels
b_concept = Concept(concept_id=9863, conceptscheme_id=conceptscheme_id, type='concept')
b_labels = [Label(label='test', language_id='nl')]
b_concept.labels = b_labels
filter_mock.all = Mock(return_value=[a_concept, b_concept])
return filter_mock
示例4: create_query_mock
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import all [as 别名]
def create_query_mock(some_class):
query_mock = Mock()
if some_class == Concept or some_class == Collection or some_class == Thing:
query_mock.filter_by = Mock(side_effect=filter_by_mock_concept)
elif some_class == ConceptScheme:
query_mock.filter_by = Mock(side_effect=filter_by_mock_conceptscheme)
query_mock.all = get_all_mock()
query_mock.options = Mock(side_effect=options_mock)
return query_mock
示例5: filter_mock
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import all [as 别名]
def filter_mock(filer, **kwargs):
filtermock = Mock()
filtermock.filter = Mock(side_effect=filter_mock)
filtermock.all = get_all_mock()
return filtermock
示例6: create_listquery_mock
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import all [as 别名]
def create_listquery_mock(some_class):
query_mock = Mock()
query_mock.all = get_all_list_mock()
return query_mock