def test_collect_hostedzones(monkeypatch, fx_hosted_zones, fx_hosted_zones_expected):
    route53 = MagicMock()
    route53.list_hosted_zones.return_value = fx_hosted_zones
    boto = get_boto_client(monkeypatch, route53)

    res = postgresql.collect_hosted_zones(conftest.pg_infrastructure_account, conftest.pg_region)

    assert res == fx_hosted_zones_expected

    boto.assert_called_with('route53', region_name=conftest.pg_region)
def test_collect_launch_configurations(monkeypatch, fx_launch_configuration, fx_launch_configuration_expected):
    asg = MagicMock()
    asg.get_paginator.return_value.paginate.return_value.build_full_result.return_value = fx_launch_configuration
    boto = get_boto_client(monkeypatch, asg)

    res = postgresql.collect_launch_configurations(conftest.pg_infrastructure_account, conftest.pg_region)

    assert res == fx_launch_configuration_expected

    asg.get_paginator.assert_called_with('describe_launch_configurations')
    boto.assert_called_with('autoscaling', region_name=conftest.pg_region)
Exemplo n.º 3
0
def test_collect_hostedzones(monkeypatch, fx_hosted_zones,
                             fx_hosted_zones_expected):
    route53 = MagicMock()
    route53.list_hosted_zones.return_value = fx_hosted_zones
    boto = get_boto_client(monkeypatch, route53)

    res = postgresql.collect_hosted_zones(conftest.pg_infrastructure_account,
                                          conftest.pg_region)

    assert res == fx_hosted_zones_expected

    boto.assert_called_with('route53', region_name=conftest.pg_region)
def test_collect_recordsets(monkeypatch, fx_recordsets, fx_ips_dnsnames, fx_hosted_zones_expected):
    postgresql.collect_hosted_zones = MagicMock(return_value=fx_hosted_zones_expected)
    route53 = MagicMock()
    route53.get_paginator.return_value.paginate.return_value.build_full_result.return_value = fx_recordsets
    boto = get_boto_client(monkeypatch, route53)

    res = postgresql.collect_recordsets(conftest.pg_infrastructure_account, conftest.pg_region)

    assert res == fx_ips_dnsnames

    route53.get_paginator.assert_called_with('list_resource_record_sets')
    boto.assert_called_with('route53', region_name=conftest.pg_region)
Exemplo n.º 5
0
def test_collect_launch_configurations(monkeypatch, fx_launch_configuration,
                                       fx_launch_configuration_expected):
    asg = MagicMock()
    asg.get_paginator.return_value.paginate.return_value.build_full_result.return_value = fx_launch_configuration
    boto = get_boto_client(monkeypatch, asg)

    res = postgresql.collect_launch_configurations(
        conftest.pg_infrastructure_account, conftest.pg_region)

    assert res == fx_launch_configuration_expected

    asg.get_paginator.assert_called_with('describe_launch_configurations')
    boto.assert_called_with('autoscaling', region_name=conftest.pg_region)
Exemplo n.º 6
0
def test_collect_recordsets(monkeypatch, fx_recordsets, fx_ips_dnsnames,
                            fx_hosted_zones_expected):
    postgresql.collect_hosted_zones = MagicMock(
        return_value=fx_hosted_zones_expected)
    route53 = MagicMock()
    route53.get_paginator.return_value.paginate.return_value.build_full_result.return_value = fx_recordsets
    boto = get_boto_client(monkeypatch, route53)

    res = postgresql.collect_recordsets(conftest.pg_infrastructure_account,
                                        conftest.pg_region)

    assert res == fx_ips_dnsnames

    route53.get_paginator.assert_called_with('list_resource_record_sets')
    boto.assert_called_with('route53', region_name=conftest.pg_region)
def test_collect_eip_addresses(monkeypatch, fx_addresses):
    ec2 = MagicMock()
    ec2.describe_addresses.return_value = fx_addresses
    boto = get_boto_client(monkeypatch, ec2)

    res = postgresql.collect_eip_addresses(conftest.pg_infrastructure_account, conftest.pg_region)

    assert res == [{'NetworkInterfaceOwnerId': '12345678',
                    'InstanceId': 'i-1234',
                    'PublicIp': '12.23.34.45',
                    'AllocationId': 'eipalloc-12345678'},
                   {'NetworkInterfaceOwnerId': '12345678',
                    'PublicIp': '22.33.44.55',
                    'AllocationId': 'eipalloc-22334455'}]

    boto.assert_called_with('ec2', region_name=conftest.pg_region)
Exemplo n.º 8
0
def test_collect_eip_addresses(monkeypatch, fx_addresses):
    ec2 = MagicMock()
    ec2.describe_addresses.return_value = fx_addresses
    boto = get_boto_client(monkeypatch, ec2)

    res = postgresql.collect_eip_addresses(conftest.pg_infrastructure_account,
                                           conftest.pg_region)

    assert res == [{
        'NetworkInterfaceOwnerId': '12345678',
        'InstanceId': 'i-1234',
        'PublicIp': '12.23.34.45',
        'AllocationId': 'eipalloc-12345678'
    }, {
        'NetworkInterfaceOwnerId': '12345678',
        'PublicIp': '22.33.44.55',
        'AllocationId': 'eipalloc-22334455'
    }]

    boto.assert_called_with('ec2', region_name=conftest.pg_region)