Skip to content

Commit a64ca09

Browse files
committed
Add unit tests for the latest changes to merge
Signed-off-by: Leandro Lucarella <[email protected]>
1 parent f06eb6a commit a64ca09

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_merge.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# License: MIT
2+
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Tests for the merge implementation."""
5+
6+
from unittest import mock
7+
8+
import pytest
9+
10+
from frequenz.channels import Receiver, merge
11+
12+
13+
async def test_empty() -> None:
14+
"""Ensure merge() raises an exception when no receivers are provided."""
15+
with pytest.raises(ValueError, match="At least one receiver must be provided"):
16+
merge()
17+
18+
19+
async def test_one() -> None:
20+
"""Ensure merge() returns the same receiver when only one is provided."""
21+
receiver = mock.MagicMock(spec=Receiver[int])
22+
23+
merge_receiver: Receiver[int] = merge(receiver)
24+
assert merge_receiver is receiver

0 commit comments

Comments
 (0)