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/")
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/')
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/')
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/')
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', )))
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/')
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',)))
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",)))
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',)))
def test_int(self): p = URLPattern('/a/{id:int}/b/') self.assertTrue(not p.is_exact) self.assertEqual(p.match('/a/42/b/'), ('', (42,)))
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",)))
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', )))
def test_int(self): p = URLPattern('/a/{id:int}/b/') self.assertTrue(not p.is_exact) self.assertEqual(p.match('/a/42/b/'), ('', (42, )))