def test_weighted_dns_load_balancer_with_different_domains(monkeypatch):
    senza.traffic.DNS_ZONE_CACHE = {}

    def my_client(rtype, *args):
        if rtype == 'route53':
            route53 = MagicMock()
            route53.list_hosted_zones.return_value = {'HostedZones': [{'Id': '/hostedzone/123456',
                                                                       'Name': 'zo.ne.dev.',
                                                                       'ResourceRecordSetCount': 23},
                                                                      {'Id': '/hostedzone/123457',
                                                                       'Name': 'zo.ne.com.',
                                                                       'ResourceRecordSetCount': 23}],
                                                      '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.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.find_ssl_certificate_arn', mock_string_result)
    monkeypatch.setattr('senza.components.elastic_load_balancer.resolve_security_groups', mock_string_result)

    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 = {}
    try:
        result = component_weighted_dns_elastic_load_balancer(definition,
                                                              configuration,
                                                              args,
                                                              info,
                                                              False,
                                                              AccountArguments('dummyregion'))
    except __HOLE__:
        pass
    except:
        assert False, 'raise unknown exception'
    else:

        print(result)
        print(configuration)
        assert False, 'doesn\'t raise a ValueError exception'
dataset/ETHPy150Open zalando-stups/senza/tests/test_components.py/test_weighted_dns_load_balancer_with_different_domains