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


Python MagicMock.arn方法代码示例

本文整理汇总了Python中unittest.mock.MagicMock.arn方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.arn方法的具体用法?Python MagicMock.arn怎么用?Python MagicMock.arn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest.mock.MagicMock的用法示例。


在下文中一共展示了MagicMock.arn方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_weighted_dns_load_balancer

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import arn [as 别名]
def test_weighted_dns_load_balancer(monkeypatch, boto_client, boto_resource):  # noqa: F811
    senza.traffic.DNS_ZONE_CACHE = {}

    configuration = {
        "Name": "test_lb",
        "SecurityGroups": "",
        "HTTPPort": "9999",
        'MainDomain': 'great.api.zo.ne',
        'VersionDomain': 'version.api.zo.ne'
    }
    info = {'StackName': 'foobar', 'StackVersion': '0.1'}
    definition = {"Resources": {}}

    args = MagicMock()
    args.region = "foo"

    mock_string_result = MagicMock()
    mock_string_result.return_value = "foo"
    monkeypatch.setattr('senza.components.elastic_load_balancer.resolve_security_groups', mock_string_result)

    m_acm = MagicMock()
    m_acm_certificate = MagicMock()
    m_acm_certificate.arn = "foo"
    m_acm.get_certificates.return_value = iter([m_acm_certificate])
    monkeypatch.setattr('senza.components.elastic_load_balancer.ACM', m_acm)

    result = component_weighted_dns_elastic_load_balancer(definition,
                                                          configuration,
                                                          args,
                                                          info,
                                                          False,
                                                          AccountArguments('dummyregion'))

    assert 'MainDomain' not in result["Resources"]["test_lb"]["Properties"]
开发者ID:alterrebe,项目名称:senza,代码行数:36,代码来源:test_components.py

示例2: test_component_load_balancer_namelength

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import arn [as 别名]
def test_component_load_balancer_namelength(monkeypatch):
    configuration = {
        "Name": "test_lb",
        "SecurityGroups": "",
        "HTTPPort": "9999",
        "HealthCheckPath": "/healthcheck"
    }
    info = {'StackName': 'foobar' * 5, 'StackVersion': '0.1'}
    definition = {"Resources": {}}

    args = MagicMock()
    args.region = "foo"

    mock_string_result = MagicMock()
    mock_string_result.return_value = "foo"
    monkeypatch.setattr('senza.components.elastic_load_balancer.resolve_security_groups', mock_string_result)

    m_acm = MagicMock()
    m_acm_certificate = MagicMock()
    m_acm_certificate.arn = "foo"
    m_acm.get_certificates.return_value = iter([m_acm_certificate])
    monkeypatch.setattr('senza.components.elastic_load_balancer.ACM', m_acm)

    result = component_elastic_load_balancer(definition, configuration, args, info, False, MagicMock())
    lb_name = result['Resources']['test_lb']['Properties']['LoadBalancerName']
    assert lb_name == 'foobarfoobarfoobarfoobarfoob-0.1'
    assert len(lb_name) == 32
开发者ID:alterrebe,项目名称:senza,代码行数:29,代码来源:test_components.py

示例3: test_component_load_balancer_cert_arn

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import arn [as 别名]
def test_component_load_balancer_cert_arn(monkeypatch):
    configuration = {
        "Name": "test_lb",
        "SecurityGroups": "",
        "HTTPPort": "9999",
        "SSLCertificateId": "foo2"
    }

    info = {'StackName': 'foobar', 'StackVersion': '0.1'}
    definition = {"Resources": {}}

    args = MagicMock()
    args.region = "foo"

    mock_string_result = MagicMock()
    mock_string_result.return_value = "foo"
    monkeypatch.setattr('senza.components.elastic_load_balancer.resolve_security_groups', mock_string_result)

    m_acm = MagicMock()
    m_acm_certificate = MagicMock()
    m_acm_certificate.arn = "foo"

    m_acm.get_certificates.return_value = iter([m_acm_certificate])

    m_acm_certificate.is_arn_certificate.return_value = True
    m_acm_certificate.get_by_arn.return_value = True

    monkeypatch.setattr('senza.components.elastic_load_balancer.ACM', m_acm)
    monkeypatch.setattr('senza.components.elastic_load_balancer.ACMCertificate', m_acm_certificate)

    # issue 105: support additional ELB properties
    result = component_elastic_load_balancer(definition, configuration, args, info, False, MagicMock())
    assert "foo2" == result["Resources"]["test_lb"]["Properties"]["Listeners"][0]["SSLCertificateId"]
开发者ID:alterrebe,项目名称:senza,代码行数:35,代码来源:test_components.py

示例4: test_component_load_balancer_idletimeout

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import arn [as 别名]
def test_component_load_balancer_idletimeout(monkeypatch):
    configuration = {
        "Name": "test_lb",
        "SecurityGroups": "",
        "HTTPPort": "9999",
        "ConnectionSettings": {"IdleTimeout": 300}
    }
    info = {'StackName': 'foobar', 'StackVersion': '0.1'}
    definition = {"Resources": {}}

    args = MagicMock()
    args.region = "foo"

    mock_string_result = MagicMock()
    mock_string_result.return_value = "foo"
    monkeypatch.setattr('senza.components.elastic_load_balancer.resolve_security_groups', mock_string_result)

    m_acm = MagicMock()
    m_acm_certificate = MagicMock()
    m_acm_certificate.arn = "foo"
    m_acm.get_certificates.return_value = iter([m_acm_certificate])
    monkeypatch.setattr('senza.components.elastic_load_balancer.ACM', m_acm)

    # issue 105: support additional ELB properties
    result = component_elastic_load_balancer(definition, configuration, args, info, False, MagicMock())
    assert 300 == result["Resources"]["test_lb"]["Properties"]["ConnectionSettings"]["IdleTimeout"]
    assert 'HTTPPort' not in result["Resources"]["test_lb"]["Properties"]
开发者ID:alterrebe,项目名称:senza,代码行数:29,代码来源:test_components.py

示例5: test_weighted_dns_load_balancer_with_different_domains

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import arn [as 别名]
def test_weighted_dns_load_balancer_with_different_domains(monkeypatch,  # noqa: F811
                                                           boto_client,
                                                           boto_resource):
    senza.traffic.DNS_ZONE_CACHE = {}

    boto_client['route53'].list_hosted_zones.return_value = {
        'HostedZones': [HOSTED_ZONE_ZO_NE_DEV,
                        HOSTED_ZONE_ZO_NE_COM],
        'IsTruncated': False,
        'MaxItems': '100'}

    configuration = {
        "Name": "test_lb",
        "SecurityGroups": "",
        "HTTPPort": "9999",
        'MainDomain': 'great.api.zo.ne.com',
        'VersionDomain': 'version.api.zo.ne.dev'
    }
    info = {'StackName': 'foobar', 'StackVersion': '0.1'}
    definition = {"Resources": {}}

    args = MagicMock()
    args.region = "foo"

    mock_string_result = MagicMock()
    mock_string_result.return_value = "foo"
    monkeypatch.setattr('senza.components.elastic_load_balancer.resolve_security_groups', mock_string_result)

    m_acm = MagicMock()
    m_acm_certificate = MagicMock()
    m_acm_certificate.arn = "foo"
    m_acm.get_certificates.return_value = iter([m_acm_certificate])
    monkeypatch.setattr('senza.components.elastic_load_balancer.ACM', m_acm)

    result = component_weighted_dns_elastic_load_balancer(definition,
                                                          configuration,
                                                          args,
                                                          info,
                                                          False,
                                                          AccountArguments('dummyregion'))

    assert 'zo.ne.com.' == result["Resources"]["test_lbMainDomain"]["Properties"]['HostedZoneName']
    assert 'zo.ne.dev.' == result["Resources"]["test_lbVersionDomain"]["Properties"]['HostedZoneName']

    configuration = {
        "Name": "test_lb",
        "SecurityGroups": "",
        "HTTPPort": "9999",
        'MainDomain': 'this.does.not.exists.com',
        'VersionDomain': 'this.does.not.exists.com'
    }
    senza.traffic.DNS_ZONE_CACHE = {}
    with pytest.raises(AttributeError):
        result = component_weighted_dns_elastic_load_balancer(definition,
                                                              configuration,
                                                              args,
                                                              info,
                                                              False,
                                                              AccountArguments('dummyregion'))
开发者ID:alterrebe,项目名称:senza,代码行数:61,代码来源:test_components.py

示例6: test_component_load_balancer_healthcheck

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import arn [as 别名]
def test_component_load_balancer_healthcheck(monkeypatch):
    configuration = {
        "Name": "test_lb",
        "SecurityGroups": "",
        "HTTPPort": "9999",
        "HealthCheckPath": "/healthcheck"
    }
    info = {'StackName': 'foobar', 'StackVersion': '0.1'}
    definition = {"Resources": {}}

    args = MagicMock()
    args.region = "foo"

    mock_string_result = MagicMock()
    mock_string_result.return_value = "foo"
    monkeypatch.setattr('senza.components.elastic_load_balancer.resolve_security_groups', mock_string_result)

    m_acm = MagicMock()
    m_acm_certificate = MagicMock()
    m_acm_certificate.arn = "foo"
    m_acm.get_certificates.return_value = iter([m_acm_certificate])
    monkeypatch.setattr('senza.components.elastic_load_balancer.ACM', m_acm)

    result = component_elastic_load_balancer(definition, configuration, args, info, False, MagicMock())
    # Defaults to HTTP
    assert "HTTP:9999/healthcheck" == result["Resources"]["test_lb"]["Properties"]["HealthCheck"]["Target"]

    # Support own health check port
    m_acm.get_certificates.return_value = iter([m_acm_certificate])
    configuration["HealthCheckPort"] = "1234"
    result = component_elastic_load_balancer(definition, configuration, args, info, False, MagicMock())
    assert "HTTP:1234/healthcheck" == result["Resources"]["test_lb"]["Properties"]["HealthCheck"]["Target"]
    del(configuration["HealthCheckPort"])

    # Supports other AWS protocols
    m_acm.get_certificates.return_value = iter([m_acm_certificate])
    configuration["HealthCheckProtocol"] = "TCP"
    result = component_elastic_load_balancer(definition, configuration, args, info, False, MagicMock())
    assert "TCP:9999/healthcheck" == result["Resources"]["test_lb"]["Properties"]["HealthCheck"]["Target"]

    # Will fail on incorrect protocol
    m_acm.get_certificates.return_value = iter([m_acm_certificate])
    configuration["HealthCheckProtocol"] = "MYFANCYPROTOCOL"
    try:
        component_elastic_load_balancer(definition, configuration, args, info, False, MagicMock())
    except click.UsageError:
        pass
    except:
        assert False, "check for supported protocols returns unknown Exception"
    else:
        assert False, "check for supported protocols failed"
开发者ID:alterrebe,项目名称:senza,代码行数:53,代码来源:test_components.py

示例7: test_weighted_dns_load_balancer

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import arn [as 别名]
def test_weighted_dns_load_balancer(monkeypatch, boto_resource):
    senza.traffic.DNS_ZONE_CACHE = {}

    def my_client(rtype, *args):
        if rtype == 'route53':
            route53 = MagicMock()
            route53.list_hosted_zones.return_value = {'HostedZones': [HOSTED_ZONE_ZO_NE_COM],
                                                      'IsTruncated': False,
                                                      'MaxItems': '100'}
            return route53
        return MagicMock()

    monkeypatch.setattr('boto3.client', my_client)

    configuration = {
        "Name": "test_lb",
        "SecurityGroups": "",
        "HTTPPort": "9999",
        'MainDomain': 'great.api.zo.ne.com',
        'VersionDomain': 'version.api.zo.ne.com'
    }
    info = {'StackName': 'foobar', 'StackVersion': '0.1'}
    definition = {"Resources": {}}

    args = MagicMock()
    args.region = "foo"

    mock_string_result = MagicMock()
    mock_string_result.return_value = "foo"
    monkeypatch.setattr('senza.components.elastic_load_balancer.resolve_security_groups', mock_string_result)

    m_acm = MagicMock()
    m_acm_certificate = MagicMock()
    m_acm_certificate.arn = "foo"
    m_acm.get_certificates.return_value = iter([m_acm_certificate])
    monkeypatch.setattr('senza.components.elastic_load_balancer.ACM', m_acm)

    result = component_weighted_dns_elastic_load_balancer(definition,
                                                          configuration,
                                                          args,
                                                          info,
                                                          False,
                                                          AccountArguments('dummyregion'))

    assert 'MainDomain' not in result["Resources"]["test_lb"]["Properties"]
开发者ID:dvinokurov,项目名称:senza,代码行数:47,代码来源:test_components.py


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