예제 #1
0
 def test_any(self):
     p = URLPattern("/a/{id:any(aaa, bbb, ccc)}/b/")
     self.assertTrue(not p.is_exact)
     self.assertEqual(p.match("/a/aaa/b/"), ('', ("aaa",)))
     self.assertEqual(p.match("/a/bbb/b/"), ('', ("bbb",)))
     self.assertEqual(p.match("/a/ccc/b/"), ('', ("ccc",)))
     self.assertRaises(NoURLPatternMatched, p.match, "/a")
     self.assertRaises(NoURLPatternMatched, p.match, "/a/abc/b/")
예제 #2
0
파일: tests.py 프로젝트: andreypopp/routr
 def test_any(self):
     p = URLPattern('/a/{id:any(aaa, bbb, ccc)}/b/')
     self.assertTrue(not p.is_exact)
     self.assertEqual(p.match('/a/aaa/b/'), ('', ('aaa',)))
     self.assertEqual(p.match('/a/bbb/b/'), ('', ('bbb',)))
     self.assertEqual(p.match('/a/ccc/b/'), ('', ('ccc',)))
     self.assertRaises(NoURLPatternMatched, p.match, '/a')
     self.assertRaises(NoURLPatternMatched, p.match, '/a/abc/b/')
예제 #3
0
파일: tests.py 프로젝트: pombredanne/routr
 def test_any(self):
     p = URLPattern('/a/{id:any(aaa, bbb, ccc)}/b/')
     self.assertTrue(not p.is_exact)
     self.assertEqual(p.match('/a/aaa/b/'), ('', ('aaa', )))
     self.assertEqual(p.match('/a/bbb/b/'), ('', ('bbb', )))
     self.assertEqual(p.match('/a/ccc/b/'), ('', ('ccc', )))
     self.assertRaises(NoURLPatternMatched, p.match, '/a')
     self.assertRaises(NoURLPatternMatched, p.match, '/a/abc/b/')
예제 #4
0
파일: tests.py 프로젝트: andreypopp/routr
    def test_str_re(self):
        p = URLPattern('/a/{id:str(re=[0-9]+)}/b/')
        self.assertTrue(not p.is_exact)
        self.assertEqual(p.match('/a/42/b/'), ('', ('42',)))
        self.assertRaises(NoURLPatternMatched, p.match, '/a/a/b/')

        p = URLPattern('/a/{id:str(re=[0-9a-f]{6})}/b/')
        self.assertTrue(not p.is_exact)
        self.assertEqual(p.match('/a/12efa3/b/'), ('', ('12efa3',)))
        self.assertRaises(NoURLPatternMatched, p.match, '/a/a/b/')
예제 #5
0
파일: tests.py 프로젝트: pombredanne/routr
    def test_str(self):
        p = URLPattern('/a/{id}/b/')
        self.assertTrue(not p.is_exact)
        self.assertEqual(p.match('/a/42/b/'), ('', ('42', )))

        p = URLPattern('/a/{id:str}/b/')
        self.assertTrue(not p.is_exact)
        self.assertEqual(p.match('/a/42/b/'), ('', ('42', )))

        p = URLPattern('/a/{id:string}/b/')
        self.assertTrue(not p.is_exact)
        self.assertEqual(p.match('/a/42/b/'), ('', ('42', )))
예제 #6
0
파일: tests.py 프로젝트: pombredanne/routr
    def test_str_re(self):
        p = URLPattern('/a/{id:str(re=[0-9]+)}/b/')
        self.assertTrue(not p.is_exact)
        self.assertEqual(p.match('/a/42/b/'), ('', ('42', )))
        self.assertRaises(NoURLPatternMatched, p.match, '/a/a/b/')

        p = URLPattern('/a/{id:str(re=[0-9a-f]{6})}/b/')
        self.assertTrue(not p.is_exact)
        self.assertEqual(p.match('/a/12efa3/b/'), ('', ('12efa3', )))
        self.assertRaises(NoURLPatternMatched, p.match, '/a/a/b/')
예제 #7
0
파일: tests.py 프로젝트: andreypopp/routr
    def test_str(self):
        p = URLPattern('/a/{id}/b/')
        self.assertTrue(not p.is_exact)
        self.assertEqual(p.match('/a/42/b/'), ('', ('42',)))

        p = URLPattern('/a/{id:str}/b/')
        self.assertTrue(not p.is_exact)
        self.assertEqual(p.match('/a/42/b/'), ('', ('42',)))

        p = URLPattern('/a/{id:string}/b/')
        self.assertTrue(not p.is_exact)
        self.assertEqual(p.match('/a/42/b/'), ('', ('42',)))
예제 #8
0
    def test_str(self):
        p = URLPattern("/a/{id}/b/")
        self.assertTrue(not p.is_exact)
        self.assertEqual(p.match("/a/42/b/"), ('', ("42",)))

        p = URLPattern("/a/{id:str}/b/")
        self.assertTrue(not p.is_exact)
        self.assertEqual(p.match("/a/42/b/"), ('', ("42",)))

        p = URLPattern("/a/{id:string}/b/")
        self.assertTrue(not p.is_exact)
        self.assertEqual(p.match("/a/42/b/"), ('', ("42",)))
예제 #9
0
파일: tests.py 프로젝트: andreypopp/routr
 def test_path(self):
     p = URLPattern('/a/{id:path}/b/')
     self.assertTrue(not p.is_exact)
     self.assertEqual(p.match('/a/42/43/b/'), ('', ('42/43',)))
예제 #10
0
파일: tests.py 프로젝트: andreypopp/routr
 def test_int(self):
     p = URLPattern('/a/{id:int}/b/')
     self.assertTrue(not p.is_exact)
     self.assertEqual(p.match('/a/42/b/'), ('', (42,)))
예제 #11
0
 def test_path(self):
     p = URLPattern("/a/{id:path}/b/")
     self.assertTrue(not p.is_exact)
     self.assertEqual(p.match("/a/42/43/b/"), ('', ("42/43",)))
예제 #12
0
파일: tests.py 프로젝트: pombredanne/routr
 def test_path(self):
     p = URLPattern('/a/{id:path}/b/')
     self.assertTrue(not p.is_exact)
     self.assertEqual(p.match('/a/42/43/b/'), ('', ('42/43', )))
예제 #13
0
파일: tests.py 프로젝트: pombredanne/routr
 def test_int(self):
     p = URLPattern('/a/{id:int}/b/')
     self.assertTrue(not p.is_exact)
     self.assertEqual(p.match('/a/42/b/'), ('', (42, )))