Repository navigation
Expand file tree
/
Copy pathtest_processor.py
More file actions
58 lines (52 loc) · 2.44 KB
/
Copy pathtest_processor.py
File metadata and controls
58 lines (52 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Message processor tests."""
from queue import Queue
from splitio.push.processor import MessageProcessor
from splitio.sync.synchronizer import Synchronizer
from splitio.push.parser import SplitChangeUpdate, SegmentChangeUpdate, SplitKillUpdate
class ProcessorTests(object):
"""Message processor test cases."""
def test_split_change(self, mocker):
"""Test split change is properly handled."""
sync_mock = mocker.Mock(spec=Synchronizer)
queue_mock = mocker.Mock(spec=Queue)
mocker.patch('splitio.push.processor.Queue', new=queue_mock)
processor = MessageProcessor(sync_mock, mocker.Mock())
update = SplitChangeUpdate('sarasa', 123, 123, None, None, None)
processor.handle(update)
assert queue_mock.mock_calls == [
mocker.call(), # construction of split queue
mocker.call(), # construction of split queue
mocker.call().put(update)
]
def test_split_kill(self, mocker):
"""Test split kill is properly handled."""
sync_mock = mocker.Mock(spec=Synchronizer)
queue_mock = mocker.Mock(spec=Queue)
mocker.patch('splitio.push.processor.Queue', new=queue_mock)
processor = MessageProcessor(sync_mock, mocker.Mock())
update = SplitKillUpdate('sarasa', 123, 456, 'some_split', 'off')
processor.handle(update)
assert queue_mock.mock_calls == [
mocker.call(), # construction of split queue
mocker.call(), # construction of split queue
mocker.call().put(update)
]
assert sync_mock.kill_split.mock_calls == [
mocker.call('some_split', 'off', 456)
]
def test_segment_change(self, mocker):
"""Test segment change is properly handled."""
sync_mock = mocker.Mock(spec=Synchronizer)
queue_mock = mocker.Mock(spec=Queue)
mocker.patch('splitio.push.processor.Queue', new=queue_mock)
processor = MessageProcessor(sync_mock, mocker.Mock())
update = SegmentChangeUpdate('sarasa', 123, 123, 'some_segment')
processor.handle(update)
assert queue_mock.mock_calls == [
mocker.call(), # construction of split queue
mocker.call(), # construction of split queue
mocker.call().put(update)
]
def test_todo(self):
"""Fix previous tests so that we validate WHICH queue the update is pushed into."""
assert NotImplementedError("DO THAT")