class TestDispatch(BaseTest):
    def setUp(self):
        self.dispatch = Dispatch(Foo, Test, Tests, Testing)
        self.req = Request.blank("/test")

    def test_match(self):
        resource = self.dispatch.match(self.req, self.dispatch.resources)
        self.assertEqual(resource, Test)

    def test_match_reverse_order(self):
        resources = sorted(self.dispatch.resources, reverse=True)
        resource = self.dispatch.match(self.req, resources)
        self.assertEqual(resource, Test)

    def test_match_prefix(self):
        req = Request.blank("/testing")
        resource = self.dispatch.match(req, self.dispatch.resources)
        self.assertEqual(resource, Testing)

    def test_match_collection(self):
        req = Request.blank("/test/1")
        resource = self.dispatch.match(req, self.dispatch.resources)
        self.assertEqual(resource, Tests)
Exemplo n.º 2
0
class TestDispatch(BaseTest):

    def setUp(self):
        self.dispatch = Dispatch(Foo, Test, Tests, Testing)
        self.req = Request.blank("/test")

    def test_match(self):
        resource = self.dispatch.match(self.req, self.dispatch.resources)
        self.assertEqual(resource, Test)

    def test_match_reverse_order(self):
        resources = sorted(self.dispatch.resources, reverse=True)
        resource = self.dispatch.match(self.req, resources)
        self.assertEqual(resource, Test)

    def test_match_prefix(self):
        req = Request.blank("/testing")
        resource = self.dispatch.match(req, self.dispatch.resources)
        self.assertEqual(resource, Testing)

    def test_match_collection(self):
        req = Request.blank("/test/1")
        resource = self.dispatch.match(req, self.dispatch.resources)
        self.assertEqual(resource, Tests)
Exemplo n.º 3
0
 def setUp(self):
     self.dispatch = Dispatch(Foo, Test, Tests, Testing)
     self.req = Request.blank("/test")
 def setUp(self):
     self.dispatch = Dispatch(Foo, Test, Tests, Testing)
     self.req = Request.blank("/test")