Beispiel #1
0
class TestRouteManager(unittest.TestCase):
    def setUp(self):
        self.route_manager = RouteManager()

    def test_init(self):
        self.assertFalse(self.route_manager._routes, '_routes should be empty')

    def test_add_route(self):
        route = mock.MagicMock(spec=Route)
        self.route_manager.add_route(route)
        self.assertIn(route, self.route_manager._routes,
                      'new route should be in _routes')

    def test_get_all_routes(self):
        route1 = mock.MagicMock(spec=Route)
        route2 = mock.MagicMock(spec=Route)
        self.route_manager.add_route(route1)
        self.route_manager.add_route(route2)
        routes = self.route_manager.get_all_routes()
        self.assertIn(route1, routes)
        self.assertIn(route2, routes)
Beispiel #2
0
class TestRouteManager(unittest.TestCase):

    def setUp(self):
        self.route_manager = RouteManager()

    def test_init(self):
        self.assertFalse(self.route_manager._routes, '_routes should be empty')

    def test_add_route(self):
        route = mock.MagicMock(spec=Route)
        self.route_manager.add_route(route)
        self.assertIn(route, self.route_manager._routes,
                      'new route should be in _routes')

    def test_get_all_routes(self):
        route1 = mock.MagicMock(spec=Route)
        route2 = mock.MagicMock(spec=Route)
        self.route_manager.add_route(route1)
        self.route_manager.add_route(route2)
        routes = self.route_manager.get_all_routes()
        self.assertIn(route1, routes)
        self.assertIn(route2, routes)
Beispiel #3
0
import json
import datetime

from collections import OrderedDict

from flask import Flask

from thorium import (
    ThoriumFlask,
    RouteManager,
    Resource,
    fields,
    Endpoint,
)

routing = RouteManager()


class PersonResource(Resource):
    id = fields.IntField(default=None)
    name = fields.CharField()
    birth_date = fields.DateTimeField()
    admin = fields.BoolField(default=False)


class CollectionParams(Resource):
    times = fields.IntField(required=True, default=1)


@routing.collection(path='/api/event/<int:event_id>/people',
                    methods=('get', 'post'),
Beispiel #4
0
 def setUp(self):
     self.route_manager = RouteManager()
Beispiel #5
0
 def setUp(self):
     self.route_manager = RouteManager()