Skip to content

Commit

Permalink
add the erased test
Browse files Browse the repository at this point in the history
  • Loading branch information
IronJam11 committed Jan 14, 2025
1 parent 1bbd2d9 commit cc46101
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tests/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def test_config_error(self):
If channel layer doesn't specify TEST_CONFIG, `make_test_backend`
should result into error.
"""

with self.assertRaises(InvalidChannelLayerError):
channel_layers.make_test_backend(DEFAULT_CHANNEL_LAYER)

Expand All @@ -38,6 +39,7 @@ def test_config_instance(self):
If channel layer provides TEST_CONFIG, `make_test_backend` should
return channel layer instance appropriate for testing.
"""

layer = channel_layers.make_test_backend(DEFAULT_CHANNEL_LAYER)
self.assertEqual(layer.expiry, 100500)

Expand All @@ -62,15 +64,28 @@ def test_override_settings(self):

@pytest.mark.asyncio
async def test_send_receive():
"""
Test that a message sent to a channel can be received correctly.
"""
layer = InMemoryChannelLayer()
message = {"type": "test.message"}
await layer.send("test.channel", message)
assert message == await layer.receive("test.channel")


@pytest.mark.parametrize(
"method",
[BaseChannelLayer().valid_channel_name, BaseChannelLayer().valid_group_name],
)
@pytest.mark.parametrize(
"channel_name,expected_valid",
[(\\_(ツ)_/¯", False), ("chat", True), ("chat" * 100, False)],
)
def test_channel_and_group_name_validation(method, channel_name, expected_valid):
if expected_valid:
method(channel_name)
else:
with pytest.raises(TypeError):
method(channel_name)


@pytest.mark.parametrize(
"name, expected_error_message",
[
Expand Down

0 comments on commit cc46101

Please sign in to comment.