-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Schematic-90] Use synapseclient user-agent string to track schematic…
… library and CLI usage (#1569) set synapseclient user strings to track schematic cli and library usage
- Loading branch information
Showing
3 changed files
with
53 additions
and
2 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
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,36 @@ | ||
from re import search | ||
from click.testing import CliRunner | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def command_line_user_agent_pattern(): | ||
yield "schematiccommandline" + "/(\\S+)" | ||
|
||
|
||
@pytest.fixture | ||
def library_user_agent_pattern(): | ||
yield "schematic" + "/(\\S+)" | ||
|
||
|
||
class TestUserAgentString: | ||
def test_user_agent_string( | ||
self, | ||
library_user_agent_pattern, | ||
command_line_user_agent_pattern, | ||
): | ||
# GIVEN the default USER_AGENT string from the synapse client | ||
from synapseclient import USER_AGENT | ||
|
||
# WHEN schematic is imported to be used as a library | ||
from schematic.__main__ import main | ||
|
||
# THEN the User-Agent string should be updated to include the schematic library client string | ||
assert search(library_user_agent_pattern, USER_AGENT["User-Agent"]) | ||
|
||
# AND when the command line is used to execute commands | ||
runner = CliRunner() | ||
result = runner.invoke(main) | ||
|
||
# THEN the User-Agent string should be updated to include the schematic command line client string | ||
assert search(command_line_user_agent_pattern, USER_AGENT["User-Agent"]) |