diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 579f4f9..b19a9cd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.0.290" + rev: "v0.0.291" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/conftest.py b/conftest.py index fc9631a..f28f6f5 100644 --- a/conftest.py +++ b/conftest.py @@ -2,11 +2,16 @@ # third party import pytest - -# This repo +from iembot.basicbot import basicbot from pyiem.database import get_dbconnc +@pytest.fixture() +def bot(): + """A basicbot.""" + return basicbot("iembot", None, xml_log_path="/tmp") + + @pytest.fixture() def dbcursor(database): """Yield a cursor for the given database.""" diff --git a/tests/test_util_channels.py b/tests/test_util_channels.py new file mode 100644 index 0000000..b20b346 --- /dev/null +++ b/tests/test_util_channels.py @@ -0,0 +1,24 @@ +"""Test things done with channel subs.""" + +import pytest +from iembot.util import ( + channels_room_add, + channels_room_del, + channels_room_list, +) + + +@pytest.mark.parametrize("database", ["mesosite"]) +def test_room_list(bot, dbcursor): + """Test listing of channel subscriptions for the room.""" + + def _local(room, msg): + """Interception.""" + assert room == "test" + + channels_room_add(dbcursor, bot, "test", "XXX") + + bot.send_groupchat = _local + channels_room_list(bot, "test") + + channels_room_del(dbcursor, bot, "test", "XXX")