# Path: rest_api_framework/controllers.py
# class WSGIDispatcher(DispatcherMiddleware):
#     """
#     WSGIDispatcher take a list of :class:`.Controller` and mount them
#     on their ressource mount point.
#     basic syntax is:
# 
#     .. code-block:: python
# 
#        app = WSGIDispatcher([FirstApp, SecondApp])
#     """
# 
#     def __init__(self, apps, name='PRAF', version='devel',
#                  base_url=None, formats=None, autodoc=True,
#                  autospore=True, hello=True):
#         if formats is None:
#             formats = []
#         endpoints = {}
#         for elem in apps:
#             endpoints["/{0}".format(elem.ressource["ressource_name"])] = elem()
#         if not formats:
#             formats = ["json"]
#         if autodoc:
#             endpoints["/schema"] = self.make_schema(apps)
#         if autospore:
#             endpoints["/spore"] = self.make_spore(apps, name, base_url,
#                                                   version)
#         if hello:
#             endpoints["/"] = self.make_hello(name, version)
# 
#         app = NotFound()
#         mounts = endpoints
#         super(WSGIDispatcher, self).__init__(app, mounts=mounts)
# 
#     def make_schema(self, apps):
#         return AutoDocGenerator(apps)
# 
#     def make_spore(self, apps, name, base_url, version):
#         return AutoSporeGenerator(apps, name, base_url, version)
# 
#     def make_hello(self, name, version):
#         return HelloGenerator(name, version)


from unittest import TestCase
from werkzeug.wrappers import BaseResponse
from werkzeug.test import Client
from app import ApiApp
from rest_api_framework.controllers import WSGIDispatcher
import json
import datetime
        resp = client.get("/address/")

        self.assertEqual(resp.status_code, 200)
        self.assertIsInstance(json.loads(resp.data)["object_list"], list)

    def test_get(self):
        client = Client(WSGIDispatcher([ApiApp]),
                        response_wrapper=BaseResponse)

        resp = client.get("/address/1/")
        self.assertEqual(resp.status_code, 200)

        resp = client.get("/400/")
        self.assertEqual(resp.status_code, 404)

    def test_create(self):
        client = Client(WSGIDispatcher([ApiApp]),
                        response_wrapper=BaseResponse)
        resp = client.post("/address/",
                           data=json.dumps({'name': 'bob', 'age': 34}))

        self.assertEqual(resp.status_code, 201)
        self.assertEqual(resp.headers['Location'],
                         "http://localhost/address/101/")

        resp = client.post("/address/",
                           data={"test": datetime.datetime.now()})
        self.assertEqual(resp.status_code, 400)

    def test_updated(self):

# Path: rest_api_framework/controllers.py
# class WSGIDispatcher(DispatcherMiddleware):
#     """
#     WSGIDispatcher take a list of :class:`.Controller` and mount them
#     on their ressource mount point.
#     basic syntax is:
# 
#     .. code-block:: python
# 
#        app = WSGIDispatcher([FirstApp, SecondApp])
#     """
# 
#     def __init__(self, apps, name='PRAF', version='devel',
#                  base_url=None, formats=None, autodoc=True,
#                  autospore=True, hello=True):
#         if formats is None:
#             formats = []
#         endpoints = {}
#         for elem in apps:
#             endpoints["/{0}".format(elem.ressource["ressource_name"])] = elem()
#         if not formats:
#             formats = ["json"]
#         if autodoc:
#             endpoints["/schema"] = self.make_schema(apps)
#         if autospore:
#             endpoints["/spore"] = self.make_spore(apps, name, base_url,
#                                                   version)
#         if hello:
#             endpoints["/"] = self.make_hello(name, version)
# 
#         app = NotFound()
#         mounts = endpoints
#         super(WSGIDispatcher, self).__init__(app, mounts=mounts)
# 
#     def make_schema(self, apps):
#         return AutoDocGenerator(apps)
# 
#     def make_spore(self, apps, name, base_url, version):
#         return AutoSporeGenerator(apps, name, base_url, version)
# 
#     def make_hello(self, name, version):
#         return HelloGenerator(name, version)


# Path: tests/test_views.py
from unittest import TestCase
from werkzeug.wrappers import BaseResponse
from werkzeug.test import Client
from app import ApiApp
from rest_api_framework.controllers import WSGIDispatcher
import json
import datetime

        resp = client.get("/address/")

        self.assertEqual(resp.status_code, 200)
        self.assertIsInstance(json.loads(resp.data)["object_list"], list)

    def test_get(self):
        client = Client(WSGIDispatcher([ApiApp]),
                        response_wrapper=BaseResponse)

        resp = client.get("/address/1/")
        self.assertEqual(resp.status_code, 200)

        resp = client.get("/400/")
        self.assertEqual(resp.status_code, 404)

    def test_create(self):
        client = Client(WSGIDispatcher([ApiApp]),
                        response_wrapper=BaseResponse)
        resp = client.post("/address/",
                           data=json.dumps({'name': 'bob', 'age': 34}))

        self.assertEqual(resp.status_code, 201)
        self.assertEqual(resp.headers['Location'],
                         "http://localhost/address/101/")

        resp = client.post("/address/",
                           data={"test": datetime.datetime.now()})
        self.assertEqual(resp.status_code, 400)

    def test_updated(self):

        client = Client(WSGIDispatcher([ApiApp]),