MCPcopy Create free account
hub / github.com/DeepL/deepl-python / test_user_agent_with_app_info

Function test_user_agent_with_app_info

tests/test_general.py:178–188  ·  view source on GitHub ↗
(mock_send)

Source from the content-addressed store, hash-verified

176
177@patch("requests.adapters.HTTPAdapter.send")
178def test_user_agent_with_app_info(mock_send):
179 mock_send.return_value = _build_test_response()
180 translator = deepl.Translator(
181 os.environ["DEEPL_AUTH_KEY"],
182 ).set_app_info("sample_python_plugin", "1.0.2")
183 translator.translate_text(example_text["EN"], target_lang="DA")
184 ua_header = mock_send.call_args[0][0].headers["User-agent"]
185 assert "requests/" in ua_header
186 assert " python/" in ua_header
187 assert "(" in ua_header
188 assert " sample_python_plugin/1.0.2" in ua_header
189
190
191@patch("requests.adapters.HTTPAdapter.send")

Callers

nothing calls this directly

Calls 3

_build_test_responseFunction · 0.85
translate_textMethod · 0.80
set_app_infoMethod · 0.45

Tested by

no test coverage detected