Example #1
0
 def test_match__returns_dict_on_angle_match(self):
     url = "/<works>"
     e = Route(url, None, None)
     matches = e._match("/oh_yea")
     self.assertIsInstance(matches, dict)
     self.assertIn('works', matches)
     self.assertEqual(matches['works'], 'oh_yea')
Example #2
0
    def test_handle__calls_on_match_with_bound_params(self):
        class Endpoint(object):
            args = {}

            def test(self, test):
                self.args['test'] = test

        e = Endpoint()
        r = Route("/<test>", e, 'test')

        _partial = r.handle('/foo')

        self.assertEqual(len(e.args), 0)
        _partial()
        self.assertEqual(len(e.args), 1)
        self.assertEqual(e.args['test'], 'foo')
Example #3
0
 def test_match__shouldnt_pick_up_longer_url(self):
     e = Route("/", None, None)
     self.assertFalse(
         e.handles_route("/NB2HI4B2F4XWO33PM5WGKLTDN5WQ====", 'GET'))
Example #4
0
 def test_compile_regex__regex_compile_returns_regex_like_thing(self):
     e = Route('/', None, None)
     self.assertTrue(hasattr(e._compile_regex('/'), 'match'))
Example #5
0
    def test_match__returns_none_on_no_match(self):
        url = "/<test>"
        e = Route(url, None, None)

        self.assertEqual(e._match("nope"), None)
Example #6
0
 def test_match__returns_dict_on_raw_match(self):
     url = "/works"
     e = Route(url, None, None)
     self.assertIsInstance(e._match("/works"), dict)
Example #7
0
 def test_handles_route__false_if_different_method(self):
     url = '/test'
     e = Route(url, None, None, methods=['POST'])
     self.assertFalse(e.handles_route(url, 'GET'))
Example #8
0
 def test_handles_route__false_if_no_match(self):
     url = "/test"
     e = Route(url, None, None)
     self.assertFalse(e.handles_route("/nottest", 'GET'))
Example #9
0
 def test_handles_route__true_if_match(self):
     url = "/test"
     e = Route(url, None, None)
     self.assertTrue(e.handles_route(url, 'GET'))