diff options
| author | salmonik <raisersoft@proton.me> | 2026-04-29 14:47:32 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-04-29 14:47:32 +0200 |
| commit | 8a4352ebb5e15ff4be82a9b4e111c1535aab349e (patch) | |
| tree | 2c4d5b4b65bdc8308b35c411cffa7f17b1bfeb4d /tests/cogs/test_vclogs.py | |
| parent | fix: fallback to plaintext if no json is provided for assistant.py (diff) | |
| parent | proper context for settings (diff) | |
| download | senator-sperma-8a4352ebb5e15ff4be82a9b4e111c1535aab349e.tar.gz senator-sperma-8a4352ebb5e15ff4be82a9b4e111c1535aab349e.zip | |
Merge branch 'dev'
Signed-off-by: salmonik <raisersoft@proton.me>
Diffstat (limited to 'tests/cogs/test_vclogs.py')
| -rw-r--r-- | tests/cogs/test_vclogs.py | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/tests/cogs/test_vclogs.py b/tests/cogs/test_vclogs.py index 2003478..17ff839 100644 --- a/tests/cogs/test_vclogs.py +++ b/tests/cogs/test_vclogs.py | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | import pytest | 1 | import pytest |
| 2 | from unittest.mock import AsyncMock, patch, MagicMock | 2 | from unittest.mock import AsyncMock, patch, MagicMock |
| 3 | import json | 3 | from conftest import MockApplicationContext |
| 4 | from tests.conftest import MockApplicationContext | ||
| 5 | 4 | ||
| 6 | 5 | ||
| 7 | def test_format_duration(): | 6 | def test_format_duration(): |
| @@ -13,20 +12,26 @@ def test_format_duration(): | |||
| 13 | 12 | ||
| 14 | 13 | ||
| 15 | def test_load_activity_data(): | 14 | def test_load_activity_data(): |
| 16 | with patch('builtins.open', MagicMock()): | 15 | with patch("cogs.vclogs.get_connection") as mock_conn: |
| 17 | with patch('os.path.exists', return_value=True): | 16 | mock_cursor = MagicMock() |
| 18 | with patch('json.load', return_value={"123": {"active": True}}): | 17 | mock_conn.return_value.cursor.return_value = mock_cursor |
| 19 | from cogs.vclogs import load_activity_data | 18 | mock_conn.return_value.close.return_value = None |
| 20 | data = load_activity_data() | 19 | mock_cursor.fetchall.return_value = [] |
| 21 | assert isinstance(data, dict) | 20 | |
| 21 | from cogs.vclogs import load_activity_data | ||
| 22 | data = load_activity_data() | ||
| 23 | assert isinstance(data, dict) | ||
| 22 | 24 | ||
| 23 | 25 | ||
| 24 | def test_save_activity_data(): | 26 | def test_save_activity_data(): |
| 25 | with patch('builtins.open', MagicMock()) as mock_open: | 27 | with patch("cogs.vclogs.get_connection") as mock_conn: |
| 26 | with patch('json.dump'): | 28 | mock_cursor = MagicMock() |
| 27 | from cogs.vclogs import save_activity_data | 29 | mock_conn.return_value.cursor.return_value = mock_cursor |
| 28 | save_activity_data({"123": {"active": True}}) | 30 | mock_conn.return_value.commit.return_value = None |
| 29 | mock_open.assert_called_once() | 31 | mock_conn.return_value.close.return_value = None |
| 32 | |||
| 33 | from cogs.vclogs import save_activity_data | ||
| 34 | save_activity_data({"123": {"active": True}}) | ||
| 30 | 35 | ||
| 31 | 36 | ||
| 32 | @pytest.fixture | 37 | @pytest.fixture |
| @@ -80,4 +85,4 @@ async def test_handle_state_change_mute_false(vclogs_cog): | |||
| 80 | 85 | ||
| 81 | tts_text, channel = await vclogs_cog.handle_state_change(mock_member, mock_channel, 'mute', False, None) | 86 | tts_text, channel = await vclogs_cog.handle_state_change(mock_member, mock_channel, 'mute', False, None) |
| 82 | 87 | ||
| 83 | assert "zrobił jajecznice" in tts_text | 88 | assert "zrobił jajecznice" in tts_text \ No newline at end of file |
