當前位置: 首頁>>代碼示例>>Python>>正文


Python Mock._data方法代碼示例

本文整理匯總了Python中asynctest.Mock._data方法的典型用法代碼示例。如果您正苦於以下問題:Python Mock._data方法的具體用法?Python Mock._data怎麽用?Python Mock._data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在asynctest.Mock的用法示例。


在下文中一共展示了Mock._data方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_matrix_build

# 需要導入模塊: from asynctest import Mock [as 別名]
# 或者: from asynctest.Mock import _data [as 別名]
def test_matrix_build(mocker, SETTINGS):
    JENKINS = mocker.patch('jenkins_epo.jenkins.JENKINS')
    from jenkins_epo.jenkins import MatrixJob, JobSpec

    SETTINGS.DRY_RUN = 0

    api_instance = Mock()
    api_instance.name = 'matrix'
    api_instance._data = {'url': 'https://jenkins/job'}
    xml = api_instance._get_config_element_tree.return_value
    xml.findall.return_value = []
    xml.find.return_value = None

    spec = JobSpec(api_instance.name)
    spec.config['parameters'] = {'PARAM': 1}

    job = MatrixJob(api_instance)
    job._node_axis = job._revision_param = None
    job._combination_param = 'C'
    job._revision_param = 'R'

    yield from job.build(
        Mock(url='url://', fullref='refs/heads/master'), spec, 'matrix',
    )

    assert JENKINS.rest.job().buildWithParameters.mock_calls
開發者ID:novafloss,項目名稱:jenkins-github-poller,代碼行數:28,代碼來源:test_jenkins.py

示例2: test_matrix_list_context_superset

# 需要導入模塊: from asynctest import Mock [as 別名]
# 或者: from asynctest.Mock import _data [as 別名]
def test_matrix_list_context_superset(JobSpec):
    from jenkins_yml import Job
    from jenkins_epo.jenkins import MatrixJob

    api_instance = Mock(spec=['_get_config_element_tree', 'get_params'])
    api_instance.name = 'matrix'
    api_instance._data = dict(activeConfigurations=[
        {'name': 'A=0,B=a'},
        {'name': 'A=1,B=a'},
        {'name': 'A=0,B=b'},
        {'name': 'A=1,B=b'},
        {'name': 'A=0,B=c'},
        {'name': 'A=1,B=c'},
    ])

    xml = api_instance._get_config_element_tree.return_value
    xml.findall.return_value = []
    xml.find.return_value = None

    jenkins_spec = JobSpec.from_xml.return_value
    jenkins_spec.config = dict(axis={'A': [0, 1], 'B': 'abc'})

    job = MatrixJob(api_instance)
    spec = Job('matrix', dict(axis={'B': 'acd'}))

    contexts = [c for c in job.list_contexts(spec)]

    haystack = '\n'.join(contexts)
    assert 'A=0' in haystack
    assert 'A=1' not in haystack
    assert 'B=b' not in haystack
    assert 2 == len(contexts)
開發者ID:novafloss,項目名稱:jenkins-github-poller,代碼行數:34,代碼來源:test_jenkins.py

示例3: test_matrix_list_context_node

# 需要導入模塊: from asynctest import Mock [as 別名]
# 或者: from asynctest.Mock import _data [as 別名]
def test_matrix_list_context_node():
    from jenkins_yml import Job
    from jenkins_epo.jenkins import MatrixJob

    api_instance = Mock(spec=['_get_config_element_tree', 'get_params'])
    api_instance.name = 'matrix'
    api_instance._data = dict(activeConfigurations=[
        {'name': 'NODE=slave-legacy,P=a'},
        {'name': 'NODE=slave-ng,P=a'},
        {'name': 'NODE=slave-legacy,P=b'},
        {'name': 'NODE=slave-ng,P=b'},
    ])

    xml = api_instance._get_config_element_tree.return_value
    xml.findall.return_value = []
    xml.find.return_value = None

    job = MatrixJob(api_instance)
    job._node_axis = 'NODE'

    spec = Job('matrix', dict(
        node='slave-ng',
        axis={'P': ['a', 'b', 4.3]},
    ))
    contexts = [c for c in job.list_contexts(spec)]

    assert 2 == len(contexts)
    assert 'NODE=slave-legacy' not in ''.join(contexts)
    assert 'NODE=slave-ng' in ''.join(contexts)
開發者ID:novafloss,項目名稱:jenkins-github-poller,代碼行數:31,代碼來源:test_jenkins.py

示例4: test_freestyle_node_param

# 需要導入模塊: from asynctest import Mock [as 別名]
# 或者: from asynctest.Mock import _data [as 別名]
def test_freestyle_node_param():
    from jenkins_epo.jenkins import FreestyleJob

    api_instance = Mock(spec=['_get_config_element_tree', 'get_params'])
    api_instance._data = dict()
    api_instance.name = 'freestyle'
    api_instance.get_params.return_value = [
        {'name': 'P', 'type': 'StringParameter'},
        {'name': 'N', 'type': 'LabelParameterDefinition'},
    ]
    xml = api_instance._get_config_element_tree.return_value
    xml.findall.return_value = []
    xml.find.return_value = None

    job = FreestyleJob(api_instance)
    assert 'N' == job.node_param
開發者ID:novafloss,項目名稱:jenkins-github-poller,代碼行數:18,代碼來源:test_jenkins.py

示例5: test_matrix_combination_param

# 需要導入模塊: from asynctest import Mock [as 別名]
# 或者: from asynctest.Mock import _data [as 別名]
def test_matrix_combination_param():
    from jenkins_epo.jenkins import MatrixJob

    api_instance = Mock(spec=['_get_config_element_tree', 'get_params'])
    api_instance.name = 'matrix'
    api_instance._data = dict()
    api_instance.get_params.return_value = [
        {'name': 'P', 'type': 'StringParameter'},
        {'name': 'C', 'type': 'MatrixCombinationsParameterDefinition'},
    ]

    xml = api_instance._get_config_element_tree.return_value
    xml.findall.return_value = []
    xml.find.return_value = None

    job = MatrixJob(api_instance)
    assert 'C' == job.combination_param
開發者ID:novafloss,項目名稱:jenkins-github-poller,代碼行數:19,代碼來源:test_jenkins.py

示例6: test_matrix_node_axis

# 需要導入模塊: from asynctest import Mock [as 別名]
# 或者: from asynctest.Mock import _data [as 別名]
def test_matrix_node_axis():
    from jenkins_epo.jenkins import MatrixJob

    api_instance = Mock(spec=['_get_config_element_tree', 'get_params'])
    api_instance.name = 'matrix'
    api_instance._data = dict()

    xml = api_instance._get_config_element_tree.return_value
    xml.findall.return_value = []
    xml.find.return_value = None

    job = MatrixJob(api_instance)

    name_element = Mock()
    name_element.text = 'NODE'
    xml.findall.return_value = [name_element]

    assert 'NODE' == job.node_axis
開發者ID:novafloss,項目名稱:jenkins-github-poller,代碼行數:20,代碼來源:test_jenkins.py


注:本文中的asynctest.Mock._data方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。