Skip to content

Commit

Permalink
add tests for user agent string setting
Browse files Browse the repository at this point in the history
  • Loading branch information
SageGJ committed Jan 28, 2025
1 parent 6003056 commit aa34633
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/unit/test_metric_collection.py
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"])

0 comments on commit aa34633

Please sign in to comment.