def test_client_paths(base_url): url_manager = urls.UrlManager(base_url, paths) for func, path, _ in paths: kwargs = {"subject": "my-subject", "version": 1} url, method = url_manager.url_for(func, **kwargs) assert base_url in url
def test_url_with_path(base_url): local_paths = [("get_cars", "cars/{car_id}", "GET"), ("create_car", "cars", "POST")] url_manager = urls.UrlManager(base_url, local_paths) url, method = url_manager.url_for("get_cars") assert base_url in url
def test_urls_generation(base_url): local_paths = [("get_cars", "cars/{car_id}", "GET"), ("create_car", "cars", "POST")] url_manager = urls.UrlManager(base_url, local_paths) url, method = url_manager.url_for("get_cars") assert url == urllib.parse.urljoin(base_url, "cars/") assert method == "GET" url, method = url_manager.url_for("get_cars", car_id=10) assert url == urllib.parse.urljoin(base_url, "cars/10") assert method == "GET" url, method = url_manager.url_for("create_car") assert url == urllib.parse.urljoin(base_url, "cars") assert method == "POST"
def test_fail_url_manager_creation(): base_url = "localhost:8081" with pytest.raises(AssertionError): urls.UrlManager(base_url, [])