-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: new headers and payload ( connection id and interval) #346
Changes from 6 commits
dbcb01a
898d8b1
69a7fde
efa1174
f609517
1eff139
e7f7b20
8c7f065
e02111f
c2e0135
b0913a6
06e8256
c1501cb
a29de36
6b66c38
a620fe1
deb7517
4b7ec00
d5338df
7dc3e9f
b5e955a
beb8b6a
e31d1ce
c1eb4b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import json | ||
import time | ||
import warnings | ||
from datetime import datetime, timezone | ||
|
@@ -1078,3 +1079,37 @@ def test_identification_headers_unique_connection_id(): | |
"UNLEASH-CONNECTION-ID" | ||
] | ||
assert connection_id_first_client != connection_id_second_client | ||
|
||
|
||
@responses.activate | ||
def test_identification_values_are_passed_in(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is testing all 3 requests, headers and body There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I remember we had this test added: https://github.com/Unleash/unleash-client-python/pull/342/files#diff-6fd6de24505791fbd1ad578927a8fdd87d15a14b7d194600d68434ddc3e53e00R1038 Are those 2 tests testing similar things? |
||
responses.add(responses.POST, URL + REGISTER_URL, json={}, status=202) | ||
responses.add( | ||
responses.GET, URL + FEATURES_URL, json=MOCK_FEATURE_RESPONSE, status=200 | ||
) | ||
responses.add(responses.POST, URL + METRICS_URL, json={}, status=202) | ||
|
||
input_interval = 1 | ||
unleash_client = UnleashClient( | ||
URL, APP_NAME, refresh_interval=input_interval, metrics_interval=1 | ||
) | ||
expected_connection_id = unleash_client.connection_id | ||
expected_interval = str(input_interval * 1000) | ||
|
||
unleash_client.initialize_client() | ||
register_request = responses.calls[0].request | ||
reqister_body = json.loads(register_request.body) | ||
|
||
assert register_request.headers["UNLEASH-CONNECTION-ID"] == expected_connection_id | ||
assert reqister_body["connectionId"] == expected_connection_id | ||
|
||
features_request = responses.calls[1].request | ||
|
||
assert features_request.headers["UNLEASH-CONNECTION-ID"] == expected_connection_id | ||
assert features_request.headers["UNLEASH-INTERVAL-ID"] == expected_interval | ||
|
||
time.sleep(2) | ||
metrics_request = responses.calls[2].request | ||
|
||
assert metrics_request.headers["UNLEASH-CONNECTION-ID"] == expected_connection_id | ||
assert metrics_request.headers["UNLEASH-INTERVAL-ID"] == expected_interval |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we had connection id before. is this code moved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was initialized only in headers before, now we can use it also in body if needed.
https://github.com/Unleash/unleash-client-python/pull/346/files#diff-d8684313c6cfe7bbd96df3385f5b28c7f337cd5159fc08f79b518df75cc13475L218