Skip to content

Commit 85fed03

Browse files
committed
Cleanup and updated tests
1 parent 0f57f4f commit 85fed03

File tree

3 files changed

+4
-40
lines changed

3 files changed

+4
-40
lines changed

splitio/engine/impressions/adapters.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,23 +130,3 @@ def _uniques_formatter(self, uniques):
130130
:rtype: json
131131
"""
132132
return [json.dumps({'f': feature, 'ks': list(keys)}) for feature, keys in uniques.items()]
133-
134-
def _build_counters(self, counters):
135-
"""
136-
Build an impression bulk formatted as the API expects it.
137-
138-
:param counters: List of impression counters per feature.
139-
:type counters: list[splitio.engine.impressions.Counter.CountPerFeature]
140-
141-
:return: dict with list of impression count dtos
142-
:rtype: dict
143-
"""
144-
return json.dumps({
145-
'pf': [
146-
{
147-
'f': pf_count.feature,
148-
'm': pf_count.timeframe,
149-
'rc': pf_count.count
150-
} for pf_count in counters
151-
]
152-
})

tests/client/test_factory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_redis_client_creation(self, mocker):
100100
assert adapter == factory._get_storage('impressions')._redis
101101
assert adapter == factory._get_storage('events')._redis
102102

103-
assert strict_redis_mock.mock_calls == [mocker.call(
103+
assert strict_redis_mock.mock_calls[0] == mocker.call(
104104
host='some_host',
105105
port=1234,
106106
db=1,
@@ -121,8 +121,8 @@ def test_redis_client_creation(self, mocker):
121121
ssl_certfile='some_cert_file',
122122
ssl_cert_reqs='some_cert_req',
123123
ssl_ca_certs='some_ca_cert',
124-
max_connections=999
125-
)]
124+
max_connections=999,
125+
)
126126
assert factory._labels_enabled is False
127127
assert isinstance(factory._recorder, PipelinedRecorder)
128128
assert isinstance(factory._recorder._impressions_manager, ImpressionsManager)

tests/engine/test_send_adapters.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,6 @@ def test_uniques_formatter(self, mocker):
5656
for i in range(0,1):
5757
assert(sorted(ast.literal_eval(sender_adapter._uniques_formatter(uniques)[i])["ks"]) == sorted(formatted[i]["ks"]))
5858

59-
def test_build_counters(self, mocker):
60-
"""Test formatting counters dict to json."""
61-
62-
counters = [
63-
Counter.CountPerFeature('f1', 123, 2),
64-
Counter.CountPerFeature('f2', 123, 123),
65-
]
66-
formatted = [
67-
{'f': 'f1', 'm': 123, 'rc': 2},
68-
{'f': 'f2', 'm': 123, 'rc': 123},
69-
]
70-
71-
sender_adapter = RedisSenderAdapter(mocker.Mock())
72-
for i in range(0,1):
73-
assert(sorted(ast.literal_eval(sender_adapter._build_counters(counters))['pf'][i]) == sorted(formatted[i]))
74-
7559
@mock.patch('splitio.storage.adapters.redis.RedisAdapter.rpush')
7660
def test_record_unique_keys(self, mocker):
7761
"""Test sending unique keys."""
@@ -85,7 +69,7 @@ def test_record_unique_keys(self, mocker):
8569

8670
assert(mocker.called)
8771

88-
@mock.patch('splitio.storage.adapters.redis.RedisAdapter.rpush')
72+
@mock.patch('splitio.storage.adapters.redis.RedisPipelineAdapter.hincrby')
8973
def test_flush_counters(self, mocker):
9074
"""Test sending counters."""
9175

0 commit comments

Comments
 (0)