Exemple #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/")
Exemple #2
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/')
Exemple #3
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/')
Exemple #4
0
    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/')
Exemple #5
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', )))
Exemple #6
0
    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/')
Exemple #7
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',)))
Exemple #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",)))
Exemple #9
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',)))
Exemple #10
0
 def test_int(self):
     p = URLPattern('/a/{id:int}/b/')
     self.assertTrue(not p.is_exact)
     self.assertEqual(p.match('/a/42/b/'), ('', (42,)))
Exemple #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",)))
Exemple #12
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', )))
Exemple #13
0
 def test_int(self):
     p = URLPattern('/a/{id:int}/b/')
     self.assertTrue(not p.is_exact)
     self.assertEqual(p.match('/a/42/b/'), ('', (42, )))