-
-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Append "cwltool" to HTTP User-Agent string (#1977)
Also appends the program name, if not "cwltool" Should work for calrissian, reana-cwl-runner, and arvados-cwl-runner, but not toil-cwl-runner which doesn't call the cwltool.main.main() function. Probably works for streamflow, but I haven't tested that. --------- Co-authored-by: Michael R. Crusoe <1330696+mr-c@users.noreply.github.com>
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import requests | ||
|
||
from cwltool.main import append_word_to_default_user_agent, main | ||
|
||
|
||
def get_user_agent() -> str: | ||
return requests.utils.default_headers()["User-Agent"] | ||
|
||
|
||
def test_cwltool_in_user_agent() -> None: | ||
"""python-requests HTTP User-Agent should include the string 'cwltool'.""" | ||
try: | ||
assert main(["--version"]) == 0 | ||
except SystemExit as err: | ||
assert err.code == 0 | ||
assert "cwltool" in get_user_agent() | ||
|
||
|
||
def test_append_word_to_default_user_agent() -> None: | ||
"""Confirm that append_word_to_default_user_agent works.""" | ||
word_to_append = "foobar123" | ||
assert word_to_append not in get_user_agent() | ||
append_word_to_default_user_agent(word_to_append) | ||
assert word_to_append in get_user_agent() |