feat: add Kurigram property notification bot

This commit is contained in:
Azimkin
2026-09-22 17:25:03 +02:00
commit bbaa093a85
17 changed files with 1038 additions and 0 deletions

41
tests/test_config.py Normal file
View File

@@ -0,0 +1,41 @@
from pathlib import Path
import pytest
from property_bot.config import load_config
def write_config(path: Path, websocket_url: str = "ws://127.0.0.1:3000/ws") -> None:
path.write_text(
f'''[telegram]
api_id = 1
api_hash = "hash"
bot_token = "token"
[admins]
user_ids = [10, 20]
[property_api]
websocket_url = "{websocket_url}"
connect_timeout_seconds = 15
reconnect_initial_delay_seconds = 1
reconnect_max_delay_seconds = 30
[database]
path = "data/bot.sqlite3"
''',
encoding="utf-8",
)
def test_loads_valid_toml_config(tmp_path: Path) -> None:
path = tmp_path / "config.toml"
write_config(path)
config = load_config(path)
assert config.telegram.api_id == 1
assert config.admin_user_ids == frozenset({10, 20})
assert config.property_api.websocket_url == "ws://127.0.0.1:3000/ws"
def test_rejects_non_websocket_url(tmp_path: Path) -> None:
path = tmp_path / "config.toml"
write_config(path, "http://127.0.0.1:3000/ws")
with pytest.raises(ValueError, match="ws://"):
load_config(path)