"""Test ELB creation functions."""
from foremast.elb.splay_health import splay_health


def test_splay():
    """Splay should split Health Checks properly."""
    health = splay_health('HTTP:80/test')
    assert health.path == '/test'
    assert health.port == '80'
    assert health.proto == 'HTTP'
    assert health.target == 'HTTP:80/test'

    health = splay_health('TCP:8000/test')
    assert health.path == ''
    assert health.port == '8000'
    assert health.proto == 'TCP'
    assert health.target == 'TCP:8000'

    health = splay_health('HTTPS:8000/test')
    assert health.path == '/test'
    assert health.port == '8000'
    assert health.proto == 'HTTPS'
    assert health.target == 'HTTPS:8000/test'

    health = splay_health('HTTPS:80')
    assert health.path == '/healthcheck'
    assert health.port == '80'
    assert health.proto == 'HTTPS'
    assert health.target == 'HTTPS:80/healthcheck'

@@ -28,16 +28,75 @@
 ons.%22%22%22%0A
+from foremast.elb.format_listeners import format_listeners%0A
 from for
@@ -952,20 +952,1147 @@
 TPS:80/healthcheck'%0A
+%0A%0Adef test_format_listeners():%0A    %22%22%22Listeners should be formatted in list of dicts.%22%22%22%0A    test = %7B%0A        'certificate': None,%0A        'i_port': 8080,%0A        'i_proto': 'HTTP',%0A        'lb_port': 80,%0A        'lb_proto': 'HTTP'%0A    %7D%0A    sample = %5B%7B%0A        'externalPort': 80,%0A        'externalProtocol': 'HTTP',%0A        'internalPort': 8080,%0A        'internalProtocol': 'HTTP',%0A        'sslCertificateId': None%0A    %7D%5D%0A%0A    results = format_listeners(elb_settings=test)%0A    for index, result in enumerate(results):%0A        assert sorted(sample%5Bindex%5D) == sorted(result)%0A    assert sample == results%0A%0A    test = %7B'ports': %5B%7B'instance': 'HTTP:8080', 'loadbalancer': 'http:80'%7D%5D%7D%0A%0A    assert sample == format_listeners(elb_settings=test)%0A%0A    test%5B'ports'%5D.append(%7B%0A        'certificate': 'kerby',%0A        'instance': 'http:80',%0A        'loadbalancer': 'https:443',%0A    %7D)%0A    sample.append(%7B%0A        'externalPort': 443,%0A        'externalProtocol': 'HTTPS',%0A        'internalPort': 80,%0A        'internalProtocol': 'HTTP',%0A        'sslCertificateId': 'kerby',%0A    %7D)%0A%0A    assert sample == format_listeners(elb_settings=test)%0A

Add test for format_listeners()