Skip to content

Commit 61a92e2

Browse files
committed
fix: tests
1 parent f2d2770 commit 61a92e2

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

tests/unit/pipeline/transformers/test_transformer.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
from hamcrest import assert_that, contains_inanyorder, has_length
66

77
from nodestream.pipeline import Flush
8-
from nodestream.pipeline.transformers import (
9-
ConcurrentTransformer,
10-
SwitchTransformer,
11-
Transformer,
12-
)
8+
from nodestream.pipeline.transformers import (ConcurrentTransformer, SwitchTransformer,
9+
Transformer, )
1310
from nodestream.pipeline.value_providers import JmespathValueProvider
1411

1512

@@ -27,11 +24,12 @@ async def transform_record(self, record):
2724

2825

2926
@pytest.mark.asyncio
30-
async def test_concurrent_transformer_alL_items_collect():
27+
async def test_concurrent_transformer_all_items_collect():
3128
items = list(range(100))
3229
add = AddOneConcurrently()
30+
mock_context = MagicMock()
3331
result = [r for i in items async for r in add.process_record(i, None)]
34-
result.extend([r async for r in add.emit_outstanding_records()])
32+
result.extend([r async for r in add.emit_outstanding_records(mock_context)])
3533
assert_that(result, contains_inanyorder(*[i + 1 for i in items]))
3634
assert_that(result, has_length(len(items)))
3735

@@ -80,23 +78,25 @@ async def downstream_client():
8078
async def test_concurrent_transformer_worker_cleanup(mocker):
8179
add = AddOneConcurrently()
8280
add.thread_pool = mocker.Mock()
83-
await add.finish(None)
81+
mock_context = MagicMock()
82+
await add.finish(mock_context)
8483
add.thread_pool.shutdown.assert_called_once_with(True)
8584

8685

8786
@pytest.mark.asyncio
88-
async def test_concurrent_transformer_flush(mocker):
87+
async def test_concurrent_transformer_flush():
8988
add = AddOneConcurrently()
89+
mock_context = MagicMock()
9090
result = [
9191
r for record in (1, Flush, 2) async for r in add.process_record(record, None)
9292
]
93-
result.extend([r async for r in add.emit_outstanding_records()])
93+
result.extend([r async for r in add.emit_outstanding_records(mock_context)])
9494
assert_that(result, contains_inanyorder(2, 3, Flush))
9595

9696

97-
class addNTransformer(Transformer):
98-
def __init__(self, N):
99-
self.n = N
97+
class AddNTransformer(Transformer):
98+
def __init__(self, n):
99+
self.n = n
100100

101101
async def transform_record(self, record):
102102
yield dict(type=record["type"], value=record["value"] + self.n)
@@ -105,17 +105,17 @@ async def transform_record(self, record):
105105
TEST_PROVIDER = JmespathValueProvider.from_string_expression("type")
106106
TEST_CASES = {
107107
"first": {
108-
"implementation": "tests.unit.pipeline.transformers.test_transformer:addNTransformer",
109-
"arguments": {"N": 1},
108+
"implementation": "tests.unit.pipeline.transformers.test_transformer:AddNTransformer",
109+
"arguments": {"n": 1},
110110
},
111111
"second": {
112-
"implementation": "tests.unit.pipeline.transformers.test_transformer:addNTransformer",
113-
"arguments": {"N": 2},
112+
"implementation": "tests.unit.pipeline.transformers.test_transformer:AddNTransformer",
113+
"arguments": {"n": 2},
114114
},
115115
}
116116
DEFAULT_CASE = {
117-
"implementation": "tests.unit.pipeline.transformers.test_transformer:addNTransformer",
118-
"arguments": {"N": 3},
117+
"implementation": "tests.unit.pipeline.transformers.test_transformer:AddNTransformer",
118+
"arguments": {"n": 3},
119119
}
120120

121121
TEST_DATA = [
@@ -164,7 +164,7 @@ async def test_switch_transformer_without_default():
164164
assert results == TEST_RESULTS_WITH_NO_DEFAULT
165165

166166

167-
class TestConcurrentTransformer(ConcurrentTransformer):
167+
class MockConcurrentTransformer(ConcurrentTransformer):
168168
def __init__(self):
169169
self.done = False
170170
self.queue_size = 0
@@ -176,6 +176,6 @@ async def transform_record(self, record):
176176

177177
@pytest.mark.asyncio
178178
async def test_emit_outstanding_records():
179-
transformer = TestConcurrentTransformer()
179+
transformer = MockConcurrentTransformer()
180180
context = MagicMock()
181181
assert transformer.emit_outstanding_records(context)

0 commit comments

Comments
 (0)