Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions UnleashClient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
StreamingConnector,
)
from UnleashClient.constants import (
APPLICATION_HEADERS,
DISABLED_VARIATION,
ETAG,
METRIC_LAST_SENT_TIME,
Expand Down Expand Up @@ -290,6 +291,7 @@ def initialize_client(self, fetch_toggles: bool = True) -> None:
start_scheduler = False
base_headers = {
**self.unleash_custom_headers,
**APPLICATION_HEADERS,
"unleash-connection-id": self.connection_id,
"unleash-appname": self.unleash_app_name,
"unleash-instanceid": self.unleash_instance_id,
Expand Down
18 changes: 18 additions & 0 deletions tests/unit_tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import re
import threading
import time
import uuid
Expand Down Expand Up @@ -1487,3 +1488,20 @@ def test_uc_bootstrap_initializes_offline_connector():
assert unleash_client.is_enabled("testFlag")

unleash_client.destroy()


@responses.activate
def test_spec_header_is_sent_when_fetching_features():
responses.add(
responses.GET, URL + FEATURES_URL, json=MOCK_FEATURE_RESPONSE, status=200
)

unleash_client = UnleashClient(
URL, APP_NAME, disable_metrics=True, disable_registration=True
)
unleash_client.initialize_client()
client_spec = responses.calls[0].request.headers["Unleash-Client-Spec"]

## assert that the client spec looks like a semver string
semver_regex = r"^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$"
assert re.match(semver_regex, client_spec)
Loading