Skip to content

Commit 60c5541

Browse files
committed
fixed tests
1 parent a9ed304 commit 60c5541

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

tests/sync/test_manager.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import threading
44
import unittest.mock as mock
55
import time
6+
import pytest
67

78
from splitio.api.auth import AuthAPI
89
from splitio.api import auth, client, APIException
@@ -73,26 +74,23 @@ def test_start_streaming_false(self, mocker):
7374
assert len(synchronizer.start_periodic_data_recording.mock_calls) == 1
7475

7576
def test_telemetry(self, mocker):
76-
httpclient = mocker.Mock(spec=client.HttpClient)
77-
token = "eyJhbGciOiJIUzI1NiIsImtpZCI6IjVZOU05US45QnJtR0EiLCJ0eXAiOiJKV1QifQ.eyJ4LWFibHktY2FwYWJpbGl0eSI6IntcIk56TTJNREk1TXpjMF9NVGd5TlRnMU1UZ3dOZz09X3NlZ21lbnRzXCI6W1wic3Vic2NyaWJlXCJdLFwiTnpNMk1ESTVNemMwX01UZ3lOVGcxTVRnd05nPT1fc3BsaXRzXCI6W1wic3Vic2NyaWJlXCJdLFwiY29udHJvbF9wcmlcIjpbXCJzdWJzY3JpYmVcIixcImNoYW5uZWwtbWV0YWRhdGE6cHVibGlzaGVyc1wiXSxcImNvbnRyb2xfc2VjXCI6W1wic3Vic2NyaWJlXCIsXCJjaGFubmVsLW1ldGFkYXRhOnB1Ymxpc2hlcnNcIl19IiwieC1hYmx5LWNsaWVudElkIjoiY2xpZW50SWQiLCJleHAiOjE2MDIwODgxMjcsImlhdCI6MTYwMjA4NDUyN30.5_MjWonhs6yoFhw44hNJm3H7_YMjXpSW105DwjjppqE"
78-
payload = '{{"pushEnabled": true, "token": "{token}"}}'.format(token=token)
79-
cfg = DEFAULT_CONFIG.copy()
80-
cfg.update({'IPAddressesEnabled': True, 'machineName': 'some_machine_name', 'machineIp': '123.123.123.123'})
81-
sdk_metadata = get_metadata(cfg)
82-
httpclient.get.return_value = client.HttpResponse(200, payload)
83-
telemetry_storage = InMemoryTelemetryStorage()
84-
telemetry_producer = TelemetryStorageProducer(telemetry_storage)
85-
telemetry_runtime_producer = telemetry_producer.get_telemetry_runtime_producer()
86-
auth_api = auth.AuthAPI(httpclient, 'some_api_key', sdk_metadata, telemetry_runtime_producer)
8777
splits_ready_event = threading.Event()
8878
synchronizer = mocker.Mock(spec=Synchronizer)
8979
telemetry_storage = InMemoryTelemetryStorage()
9080
telemetry_producer = TelemetryStorageProducer(telemetry_storage)
9181
telemetry_runtime_producer = telemetry_producer.get_telemetry_runtime_producer()
92-
manager = Manager(splits_ready_event, synchronizer, auth_api, True, sdk_metadata, telemetry_runtime_producer)
93-
manager.start()
82+
manager = Manager(splits_ready_event, synchronizer, mocker.Mock(), True, SdkMetadata('1.0', 'some', '1.2.3.4'), telemetry_runtime_producer)
83+
try:
84+
manager.start()
85+
except:
86+
pass
87+
splits_ready_event.wait(2)
88+
89+
manager._queue.put(Status.PUSH_SUBSYSTEM_UP)
90+
manager._queue.put(Status.PUSH_NONRETRYABLE_ERROR)
9491
time.sleep(1)
95-
manager._push_status_handler_active = True
92+
assert(telemetry_storage._streaming_events._streaming_events[len(telemetry_storage._streaming_events._streaming_events)-2]._type == StreamingEventTypes.SYNC_MODE_UPDATE.value)
93+
assert(telemetry_storage._streaming_events._streaming_events[len(telemetry_storage._streaming_events._streaming_events)-2]._data == SSESyncMode.STREAMING.value)
9694
assert(telemetry_storage._streaming_events._streaming_events[len(telemetry_storage._streaming_events._streaming_events)-1]._type == StreamingEventTypes.SYNC_MODE_UPDATE.value)
9795
assert(telemetry_storage._streaming_events._streaming_events[len(telemetry_storage._streaming_events._streaming_events)-1]._data == SSESyncMode.POLLING.value)
9896

tests/sync/test_splits_synchronizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def test_split_condition_sanitization(self, mocker):
500500
target_split = splits_json["splitChange1_1"]["splits"].copy()
501501
target_split[0]["conditions"][0]['partitions'][0]['size'] = 0
502502
target_split[0]["conditions"][0]['partitions'][1]['size'] = 100
503-
split[0]["conditions"] = None
503+
del split[0]["conditions"]
504504
assert (split_synchronizer._sanitize_split_elements(split) == target_split)
505505

506506
# test missing ALL_KEYS condition matcher with default rule set to 100% off

0 commit comments

Comments
 (0)