def test_init(self, header_name, header_value, expected_error,
               expected_name, expected_value):
     if expected_error is None:
         api_http_header = api_http_headers.ApiHttpHeader(
             header_name, header_value)
         assert api_http_header.name == expected_name and api_http_header.value == expected_value
     else:
         with pytest.raises(expected_error):
             api_http_headers.ApiHttpHeader(header_name, header_value)
def test_set_api_headers_on_api_client(mocker, mock_api_client):
    headers = [
        api_http_headers.ApiHttpHeader("foo", "bar"),
        api_http_headers.ApiHttpHeader("bar", "foo")
    ]
    api_http_headers.set_api_headers_on_api_client(mock_api_client, headers)
    mock_api_client.set_default_header.assert_has_calls([
        mocker.call(headers[0].name, headers[0].value),
        mocker.call(headers[1].name, headers[1].value),
    ])
def file_based_headers(tmp_path):
    yaml_document = """
    headers:
      Custom-Header: Foo
    """
    custom_api_http_headers_yaml_file_path = tmp_path / "custom_api_http_headers.yaml"
    custom_api_http_headers_yaml_file_path.write_text(yaml_document)
    expected_headers = [api_http_headers.ApiHttpHeader("Custom-Header", "Foo")]
    return custom_api_http_headers_yaml_file_path, expected_headers
@pytest.fixture
def api_http_header_env_var():
    os.environ["API_HTTP_HEADER_IN_ENV_VAR"] = "bar"
    yield "bar"
    del os.environ["API_HTTP_HEADER_IN_ENV_VAR"]


@pytest.mark.parametrize(
    "yaml_document, expected_api_http_headers, expected_error",
    [
        (
            """
    headers:
      Content-Type: ${API_HTTP_HEADER_IN_ENV_VAR}
    """,
            [api_http_headers.ApiHttpHeader("Content-Type", "bar")],
            None,
        ),
        (
            """
    headers:
      Content-Type: application/json
    """,
            [
                api_http_headers.ApiHttpHeader("Content-Type",
                                               "application/json")
            ],
            None,
        ),
        (
            """
def option_based_headers():
    return ["Another-Custom-Header", "Bar"], [api_http_headers.ApiHttpHeader("Another-Custom-Header", "Bar")]