def test_format_incorrect_endpoint(self): # https://github.com/Azure/azure-sdk-for-python/pull/12106 client = PipelineClientBase('{Endpoint}/text/analytics/v3.0') with pytest.raises(ValueError) as exp: client.format_url("foo/bar") assert str( exp.value ) == "The value provided for the url part Endpoint was incorrect, and resulted in an invalid url"
def test_request_text(self): client = PipelineClientBase('http://example.org') request = client.get("/", content="foo") # In absence of information, everything is JSON (double quote added) assert request.data == json.dumps("foo") request = client.post("/", headers={'content-type': 'text/whatever'}, content="foo") # We want a direct string assert request.data == "foo"
def test_request_text(port, http_request): client = PipelineClientBase("http://localhost:{}".format(port)) if is_rest(http_request): request = http_request("GET", "/", json="foo") else: request = client.get("/", content="foo") # In absence of information, everything is JSON (double quote added) assert request.data == json.dumps("foo") if is_rest(http_request): request = http_request("POST", "/", headers={'content-type': 'text/whatever'}, content="foo") else: request = client.post("/", headers={'content-type': 'text/whatever'}, content="foo") # We want a direct string assert request.data == "foo"
def test_format_url_no_base_url(self): client = PipelineClientBase(None) formatted = client.format_url("https://google.com/subpath/{foo}", foo="bar") assert formatted == "https://google.com/subpath/bar"
def test_format_url_full_url(self): client = PipelineClientBase("https://bing.com/path") formatted = client.format_url("https://google.com/subpath/{foo}", foo="bar") assert formatted == "https://google.com/subpath/bar"
def test_format_url_extra_path_missing_values_with_query(self): client = PipelineClientBase("https://bing.com/path?query=testvalue&x=2ndvalue") formatted = client.format_url("/subpath/{foo}") assert formatted == "https://bing.com/path/subpath?query=testvalue&x=2ndvalue"
def test_format_url_extra_path_missing_values(self): client = PipelineClientBase("https://bing.com/path") formatted = client.format_url("/subpath/{foo}") assert formatted == "https://bing.com/path/subpath"
def test_format_url_complex_params(self): client = PipelineClientBase("https://bing.com/path") formatted = client.format_url("/subpath/{a}/{b}/foo/{c}/bar", a="X", c="Y") assert formatted == "https://bing.com/path/subpath/X/foo/Y/bar"
def test_format_url_with_query(self): client = PipelineClientBase("https://bing.com/path?query=testvalue&x=2ndvalue") formatted = client.format_url("/{foo}", foo="bar") assert formatted == "https://bing.com/path/bar?query=testvalue&x=2ndvalue"
def test_format_url_basic(self): client = PipelineClientBase("https://bing.com") formatted = client.format_url("/{foo}", foo="bar") assert formatted == "https://bing.com/bar"
def test_format_url_extra_path(): client = PipelineClientBase("https://bing.com/path") formatted = client.format_url("/subpath/{foo}", foo="bar") assert formatted == "https://bing.com/path/subpath/bar"
def test_format_url_missing_param_values(): client = PipelineClientBase("https://bing.com/path") formatted = client.format_url("/{foo}") assert formatted == "https://bing.com/path"