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


Python Mock.all方法代码示例

本文整理汇总了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
开发者ID:dieuska,项目名称:atramhasis,代码行数:10,代码来源:test_validation.py

示例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
开发者ID:OnroerendErfgoed,项目名称:atramhasis,代码行数:13,代码来源:test_validation.py

示例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
开发者ID:JDeVos,项目名称:atramhasis,代码行数:33,代码来源:test_views.py

示例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
开发者ID:JDeVos,项目名称:atramhasis,代码行数:11,代码来源:test_views.py

示例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
开发者ID:JDeVos,项目名称:atramhasis,代码行数:7,代码来源:test_views.py

示例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
开发者ID:JDeVos,项目名称:atramhasis,代码行数:6,代码来源:test_views.py


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