Skip to content

Commit 1a59f04

Browse files
committed
AsyncAPI 3.0.0 Redis publisher tests
1 parent ef3f6e5 commit 1a59f04

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from faststream.asyncapi.generate import get_app_schema
2+
from faststream.redis import RedisBroker
3+
from tests.asyncapi.base.v3_0_0.publisher import PublisherTestcase
4+
5+
6+
class TestArguments(PublisherTestcase):
7+
broker_class = RedisBroker
8+
9+
def test_channel_publisher(self):
10+
broker = self.broker_class()
11+
12+
@broker.publisher("test")
13+
async def handle(msg): ...
14+
15+
schema = get_app_schema(self.build_app(broker)).to_jsonable()
16+
key = tuple(schema["channels"].keys())[0] # noqa: RUF015
17+
18+
assert schema["channels"][key]["bindings"] == {
19+
"redis": {
20+
"bindingVersion": "custom",
21+
"channel": "test",
22+
"method": "publish",
23+
}
24+
}
25+
26+
def test_list_publisher(self):
27+
broker = self.broker_class()
28+
29+
@broker.publisher(list="test")
30+
async def handle(msg): ...
31+
32+
schema = get_app_schema(self.build_app(broker)).to_jsonable()
33+
key = tuple(schema["channels"].keys())[0] # noqa: RUF015
34+
35+
assert schema["channels"][key]["bindings"] == {
36+
"redis": {"bindingVersion": "custom", "channel": "test", "method": "rpush"}
37+
}
38+
39+
def test_stream_publisher(self):
40+
broker = self.broker_class()
41+
42+
@broker.publisher(stream="test")
43+
async def handle(msg): ...
44+
45+
schema = get_app_schema(self.build_app(broker)).to_jsonable()
46+
key = tuple(schema["channels"].keys())[0] # noqa: RUF015
47+
48+
assert schema["channels"][key]["bindings"] == {
49+
"redis": {"bindingVersion": "custom", "channel": "test", "method": "xadd"}
50+
}

0 commit comments

Comments
 (0)