4
4
5
5
import pytest
6
6
from aiokafka import AIOKafkaConsumer
7
- from asphalt .core import Context , add_resource , get_resource_nowait
7
+ from asphalt .core import Context , add_resource , get_resource_nowait , start_component
8
8
9
9
from asphalt .kafka import KafkaConsumerComponent
10
10
@@ -23,14 +23,17 @@ async def test_default_settings() -> None:
23
23
)
24
24
async def test_existing_resource (lookup : bool ) -> None :
25
25
consumer = AIOKafkaConsumer ()
26
- component = KafkaConsumerComponent (
27
- existing_resource = "default" if lookup else consumer , resource_name = "alt"
28
- )
29
26
async with Context ():
30
27
if lookup :
31
28
add_resource (consumer )
32
29
33
- await component .start ()
30
+ await start_component (
31
+ KafkaConsumerComponent ,
32
+ {
33
+ "existing_resource" : "default" if lookup else consumer ,
34
+ "resource_name" : "alt" ,
35
+ },
36
+ )
34
37
assert get_resource_nowait (AIOKafkaConsumer , "alt" ) is consumer
35
38
36
39
@@ -47,11 +50,13 @@ async def test_existing_resource_conflict() -> None:
47
50
)
48
51
async def test_ssl_context (lookup : bool ) -> None :
49
52
ssl_context = ssl .create_default_context ()
50
- component = KafkaConsumerComponent (ssl_context = "default" if lookup else ssl_context )
51
53
async with Context ():
52
54
if lookup :
53
55
add_resource (ssl_context )
54
56
55
- await component .start ()
57
+ await start_component (
58
+ KafkaConsumerComponent ,
59
+ {"ssl_context" : "default" if lookup else ssl_context },
60
+ )
56
61
consumer = get_resource_nowait (AIOKafkaConsumer )
57
62
assert consumer ._client ._ssl_context is ssl_context
0 commit comments