def test_endswith(self): path_patter = '/{test}/test' full_url_pattern = '/test1/test/test2/test' result = search(path_patter, full_url_pattern) assert result.named == { 'test': 'test2', }
def test_exact(self): path_patter = '/{test}/test' full_url_pattern = '/test/test' result = search(path_patter, full_url_pattern) assert result.named == { 'test': 'test', }
def test_endswith(self): path_patter = "/{test}/test" full_url_pattern = "/test1/test/test2/test" result = search(path_patter, full_url_pattern) assert result.named == { "test": "test2", }
def test_exact(self): path_patter = "/{test}/test" full_url_pattern = "/test/test" result = search(path_patter, full_url_pattern) assert result.named == { "test": "test", }
def _get_paths_iter(self, full_url_pattern): for path_pattern, path in iteritems(self.spec.paths): # simple path if full_url_pattern.endswith(path_pattern): path_result = TemplateResult(path_pattern, {}) yield (path, path_result) # template path else: result = search(path_pattern, full_url_pattern) if result: path_result = TemplateResult(path_pattern, result.named) yield (path, path_result)
def _get_paths_iter(self, full_url_pattern): template_paths = [] for path_pattern, path in iteritems(self.spec.paths): # simple path. # Return right away since it is always the most concrete if full_url_pattern.endswith(path_pattern): path_result = TemplateResult(path_pattern, {}) yield (path, path_result) # template path else: result = search(path_pattern, full_url_pattern) if result: path_result = TemplateResult(path_pattern, result.named) template_paths.append((path, path_result)) # Fewer variables -> more concrete path for path in sorted(template_paths, key=lambda p: len(p[1].variables)): yield path