# Path: shpkpr/deployment/bluegreen/prepare.py
# def prepare_app_definition(app_definition, old_app_definition=None, apps_state=None, marathon_info=None):
#     """Prepares ``app_definition`` for blue/green deployment by adding the
#     necessary Marathon labels and setting the ID and service port.
# 
#     If an old app definition is passed in, it will be used to correctly pick the
#     color and port for the new deployment, otherwise we default to "blue" and
#     use the ports as defined in the new app definition.
#     """
#     # make a deep copy of the new app definition before we start mutating it so
#     # we can refer back to properties of the original as needed.
#     new_app_definition = copy.deepcopy(app_definition)
# 
#     if old_app_definition is not None:
#         _rotate_colour(new_app_definition, old_app_definition)
#         _rotate_port(new_app_definition, old_app_definition)
#     else:
#         _set_app_colour(new_app_definition, 'blue')
#         _init_ports(new_app_definition, apps_state, marathon_info)
# 
#     new_app_definition['id'] = new_app_definition['id'] + '-' + _get_app_colour(new_app_definition)
#     new_app_definition['labels']['HAPROXY_APP_ID'] = app_definition['id']
#     new_app_definition['labels']['HAPROXY_DEPLOYMENT_STARTED_AT'] = datetime.now().isoformat()
#     new_app_definition['labels']['HAPROXY_DEPLOYMENT_TARGET_INSTANCES'] = str(new_app_definition['instances'])
#     return new_app_definition


import pytest
from shpkpr.deployment.bluegreen.prepare import prepare_app_definition
# third-party imports

# local imports


@pytest.fixture
def app_definition(json_fixture):
    """Prepare an app definition for deployment.

    This fixture prepares an app and assumes that an existing stack is present
    on Marathon.
    """
    new_app_definition_fixture = json_fixture("marathon/bluegreen_app_new")
    old_app_definition_fixture = json_fixture("marathon/bluegreen_app_existing")
    app_states_fixture = json_fixture("valid_apps")
    info_definition_fixture = json_fixture("marathon/info")

# Path: shpkpr/deployment/bluegreen/prepare.py
# def prepare_app_definition(app_definition, old_app_definition=None, apps_state=None, marathon_info=None):
#     """Prepares ``app_definition`` for blue/green deployment by adding the
#     necessary Marathon labels and setting the ID and service port.
# 
#     If an old app definition is passed in, it will be used to correctly pick the
#     color and port for the new deployment, otherwise we default to "blue" and
#     use the ports as defined in the new app definition.
#     """
#     # make a deep copy of the new app definition before we start mutating it so
#     # we can refer back to properties of the original as needed.
#     new_app_definition = copy.deepcopy(app_definition)
# 
#     if old_app_definition is not None:
#         _rotate_colour(new_app_definition, old_app_definition)
#         _rotate_port(new_app_definition, old_app_definition)
#     else:
#         _set_app_colour(new_app_definition, 'blue')
#         _init_ports(new_app_definition, apps_state, marathon_info)
# 
#     new_app_definition['id'] = new_app_definition['id'] + '-' + _get_app_colour(new_app_definition)
#     new_app_definition['labels']['HAPROXY_APP_ID'] = app_definition['id']
#     new_app_definition['labels']['HAPROXY_DEPLOYMENT_STARTED_AT'] = datetime.now().isoformat()
#     new_app_definition['labels']['HAPROXY_DEPLOYMENT_TARGET_INSTANCES'] = str(new_app_definition['instances'])
#     return new_app_definition


# Path: tests/deployment/bluegreen/prepare/test_existing_deploy.py
import pytest
from shpkpr.deployment.bluegreen.prepare import prepare_app_definition

# third-party imports

# local imports


@pytest.fixture
def app_definition(json_fixture):
    """Prepare an app definition for deployment.

    This fixture prepares an app and assumes that an existing stack is present
    on Marathon.
    """
    new_app_definition_fixture = json_fixture("marathon/bluegreen_app_new")
    old_app_definition_fixture = json_fixture("marathon/bluegreen_app_existing")
    app_states_fixture = json_fixture("valid_apps")
    info_definition_fixture = json_fixture("marathon/info")

    return prepare_app_definition(new_app_definition_fixture,