# Path: chaosmonkey/api/hal.py
# class Document(BaseDocument):
#     """Constructs a ``HAL`` document.
#     """
# 
#     def __init__(self, data=None, links=None, embedded=None, external_self=False):
#         """Initialises a new ``HAL`` Document instance. If no arguments are
#         provided a minimal viable ``HAL`` Document is created.
# 
#         Keyword Args:
#             data (dict): Data for the document
#             links (chaosmonkey.api.hal.link.Collection): A collection of ``HAL`` links
#             embedded: TBC
#             external_self: use a fully-qualified link for self
# 
#         Raises:
#             TypeError: If ``links`` is not a :class:`chaosmonkey.api.hal.link.Collection`
#         """
#         super(Document, self).__init__(data, links, embedded)
#         self.links.append(Self(external=external_self))


from datetime import datetime, timedelta
from flask import url_for, json
from chaosmonkey.api.hal import Document
import test.attacks.attack1 as attack1_module
import test.planners.planner1 as planner1_module
        assert res.status_code == 200
        assert res.mimetype == "application/hal+json"
        assert res.json == Document(data={"plans": []}).to_dict()


def test_plan_list_return_hal(app, manager):
    url = url_for("plans.list_plans")

    plan = manager.add_plan("plan name")

    with app.test_request_context(url):

        plan_list = [plan.to_dict()]

        res = app.test_client().get(url)
        assert res.status_code == 200
        assert res.mimetype == "application/hal+json"
        assert res.json == Document(data={"plans": plan_list}).to_dict()


def test_plan_get_return_hal_with_executors(app, manager):
    plan = manager.add_plan("plan name")
    run_time = datetime.now() + timedelta(hours=10)
    executor = manager.add_executor(run_time, "executor name", {}, plan.id)

    url = url_for("plans.get_plan", plan_id=plan.id)

    with app.test_request_context(url):
        res = app.test_client().get(url)


# Path: chaosmonkey/api/hal.py
# class Document(BaseDocument):
#     """Constructs a ``HAL`` document.
#     """
# 
#     def __init__(self, data=None, links=None, embedded=None, external_self=False):
#         """Initialises a new ``HAL`` Document instance. If no arguments are
#         provided a minimal viable ``HAL`` Document is created.
# 
#         Keyword Args:
#             data (dict): Data for the document
#             links (chaosmonkey.api.hal.link.Collection): A collection of ``HAL`` links
#             embedded: TBC
#             external_self: use a fully-qualified link for self
# 
#         Raises:
#             TypeError: If ``links`` is not a :class:`chaosmonkey.api.hal.link.Collection`
#         """
#         super(Document, self).__init__(data, links, embedded)
#         self.links.append(Self(external=external_self))


# Path: test/unit/chaosmonkey/api/plans_blueprint_test.py
from datetime import datetime, timedelta
from flask import url_for, json
from chaosmonkey.api.hal import Document
import test.attacks.attack1 as attack1_module
import test.planners.planner1 as planner1_module

        assert res.status_code == 200
        assert res.mimetype == "application/hal+json"
        assert res.json == Document(data={"plans": []}).to_dict()


def test_plan_list_return_hal(app, manager):
    url = url_for("plans.list_plans")

    plan = manager.add_plan("plan name")

    with app.test_request_context(url):

        plan_list = [plan.to_dict()]

        res = app.test_client().get(url)
        assert res.status_code == 200
        assert res.mimetype == "application/hal+json"
        assert res.json == Document(data={"plans": plan_list}).to_dict()


def test_plan_get_return_hal_with_executors(app, manager):
    plan = manager.add_plan("plan name")
    run_time = datetime.now() + timedelta(hours=10)
    executor = manager.add_executor(run_time, "executor name", {}, plan.id)

    url = url_for("plans.get_plan", plan_id=plan.id)

    with app.test_request_context(url):
        res = app.test_client().get(url)


        expected = Document(data=plan.to_dict(), embedded={"executors": [executor.to_dict()]}).to_dict()