import pytest
import six


@pytest.fixture
def service_internal_ports():
    return {
        'oneport': [59001, ],
        'twoports': [59002, 59003]
    }


def test_docker_fixture_services(docker_fixture, service_internal_ports):
    for service_name, ports in six.iteritems(service_internal_ports):
        service = docker_fixture.services[service_name]
        for container in service:
            docker_ports = container.addresses.keys()
            assert sorted(ports) == sorted(docker_ports)


def test_docker_fixture_ports(docker_fixture, service_internal_ports):
    for service_name, port_mapping in six.iteritems(docker_fixture.ports):
        internal_ports = port_mapping.keys()
        assert sorted(service_internal_ports[service_name]) == sorted(internal_ports)


def test_docker_get_first_container(docker_fixture, service_internal_ports):
    for name, ports in six.iteritems(service_internal_ports):
        for port in ports:
            address = docker_fixture.get_first_address_by_service(name, port)
            assert docker_fixture.ports[name][port][0] == address.port

@@ -4,95 +4,31 @@
 ort 
-pytest%0Aimport six%0A%0A%0A@pytest.fixture%0Adef service_internal_ports():%0A    return %7B%0A   
+six%0A%0A%0ASERVICES = %7B%0A
     
- 
 'one
@@ -45,20 +45,16 @@
 001, %5D,%0A
-    
     'two
@@ -76,20 +76,16 @@
  59003%5D%0A
-    
 %7D%0A%0A%0Adef 
@@ -131,32 +131,8 @@
 ture
-, service_internal_ports
 ):%0A 
@@ -175,38 +175,24 @@
 eritems(
-service_internal_ports
+SERVICES
 ):%0A     
@@ -437,32 +437,8 @@
 ture
-, service_internal_ports
 ):%0A 
@@ -578,38 +578,24 @@
  sorted(
-service_internal_ports
+SERVICES
 %5Bservice
@@ -684,32 +684,8 @@
 ture
-, service_internal_ports
 ):%0A 
@@ -724,30 +724,16 @@
 ems(
-service_internal_ports
+SERVICES
 ):%0A 
@@ -907,8 +907,468 @@
 ss.port%0A
+%0A%0Adef test_docker_scale(docker_fixture):%0A    client = docker_fixture.docker_client%0A    assert len(docker_fixture.services%5B'oneport'%5D) == 1%0A    for service in client.project.services:%0A        if service.name == 'oneport':%0A            service.scale(2)%0A            break%0A    else:%0A        raise ValueError(%22No service 'oneport'%22)%0A    assert len(docker_fixture.services%5B'oneport'%5D) == 2%0A    service.scale(1)%0A    assert len(docker_fixture.services%5B'oneport'%5D) == 1%0A

Test scaling services