# Path: marathon/models/deployment.py
# class MarathonDeployment(MarathonResource):
# 
#     """Marathon Application resource.
# 
#     See: https://mesosphere.github.io/marathon/docs/rest-api.html#deployments
#          https://mesosphere.github.io/marathon/docs/generated/api.html#v2_deployments_get
# 
#     :param list[str] affected_apps: list of affected app ids
#     :param current_actions: current actions
#     :type current_actions: list[:class:`marathon.models.deployment.MarathonDeploymentAction`] or list[dict]
#     :param int current_step: current step
#     :param str id: deployment id
#     :param steps: deployment steps
#     :type steps: list[:class:`marathon.models.deployment.MarathonDeploymentAction`] or list[dict]
#     :param int total_steps: total number of steps
#     :param str version: version id
#     :param str affected_pods: list of strings
#     """
# 
#     def __init__(self, affected_apps=None, current_actions=None, current_step=None, id=None, steps=None,
#                  total_steps=None, version=None, affected_pods=None):
#         self.affected_apps = affected_apps
#         self.current_actions = [
#             a if isinstance(
#                 a, MarathonDeploymentAction) else MarathonDeploymentAction.from_json(a)
#             for a in (current_actions or [])
#         ]
#         self.current_step = current_step
#         self.id = id
#         self.steps = [self.parse_deployment_step(step) for step in (steps or [])]
#         self.total_steps = total_steps
#         self.version = version
#         self.affected_pods = affected_pods
# 
#     def parse_deployment_step(self, step):
#         if step.__class__ == dict:
#             # This is what Marathon 1.0.0 returns: steps
#             return MarathonDeploymentStep().from_json(step)
#         elif step.__class__ == list:
#             # This is Marathon < 1.0.0 style, a list of actions
#             return [s if isinstance(s, MarathonDeploymentAction) else MarathonDeploymentAction.from_json(s) for s in step]
#         else:
#             return step


from marathon.models.deployment import MarathonDeployment
import unittest


class MarathonDeploymentTest(unittest.TestCase):

    def test_env_defaults_to_empty_dict(self):
        """
        é testé
        """
        deployment_json = {
                "id": "ID",
                "version": "2020-05-30T07:35:04.695Z",
                "affectedApps": ["/app"],
                "affectedPods": [],
                "steps": [{
                    "actions": [{
                        "action": "RestartApplication",
                        "app": "/app"
                    }]
                }],
                "currentActions": [{
                    "action": "RestartApplication",
                    "app": "/app",
                    "readinessCheckResults": []
                }],
                "currentStep": 1,
                "totalSteps": 1
        }


# Path: marathon/models/deployment.py
# class MarathonDeployment(MarathonResource):
# 
#     """Marathon Application resource.
# 
#     See: https://mesosphere.github.io/marathon/docs/rest-api.html#deployments
#          https://mesosphere.github.io/marathon/docs/generated/api.html#v2_deployments_get
# 
#     :param list[str] affected_apps: list of affected app ids
#     :param current_actions: current actions
#     :type current_actions: list[:class:`marathon.models.deployment.MarathonDeploymentAction`] or list[dict]
#     :param int current_step: current step
#     :param str id: deployment id
#     :param steps: deployment steps
#     :type steps: list[:class:`marathon.models.deployment.MarathonDeploymentAction`] or list[dict]
#     :param int total_steps: total number of steps
#     :param str version: version id
#     :param str affected_pods: list of strings
#     """
# 
#     def __init__(self, affected_apps=None, current_actions=None, current_step=None, id=None, steps=None,
#                  total_steps=None, version=None, affected_pods=None):
#         self.affected_apps = affected_apps
#         self.current_actions = [
#             a if isinstance(
#                 a, MarathonDeploymentAction) else MarathonDeploymentAction.from_json(a)
#             for a in (current_actions or [])
#         ]
#         self.current_step = current_step
#         self.id = id
#         self.steps = [self.parse_deployment_step(step) for step in (steps or [])]
#         self.total_steps = total_steps
#         self.version = version
#         self.affected_pods = affected_pods
# 
#     def parse_deployment_step(self, step):
#         if step.__class__ == dict:
#             # This is what Marathon 1.0.0 returns: steps
#             return MarathonDeploymentStep().from_json(step)
#         elif step.__class__ == list:
#             # This is Marathon < 1.0.0 style, a list of actions
#             return [s if isinstance(s, MarathonDeploymentAction) else MarathonDeploymentAction.from_json(s) for s in step]
#         else:
#             return step


# Path: tests/test_model_deployment.py
from marathon.models.deployment import MarathonDeployment
import unittest



class MarathonDeploymentTest(unittest.TestCase):

    def test_env_defaults_to_empty_dict(self):
        """
        é testé
        """
        deployment_json = {
                "id": "ID",
                "version": "2020-05-30T07:35:04.695Z",
                "affectedApps": ["/app"],
                "affectedPods": [],
                "steps": [{
                    "actions": [{
                        "action": "RestartApplication",
                        "app": "/app"
                    }]
                }],
                "currentActions": [{
                    "action": "RestartApplication",
                    "app": "/app",
                    "readinessCheckResults": []
                }],
                "currentStep": 1,
                "totalSteps": 1
        }


        deployment = MarathonDeployment.from_json(deployment_json)