feat: matrix-hermes project structure and Matrix authentication
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""Test configuration for matrix-hermes."""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
# Add src to path for imports
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "src"))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def clean_env(monkeypatch):
|
||||
"""Remove Matrix env vars for clean test state."""
|
||||
for key in list(os.environ):
|
||||
if key.startswith("MATRIX_"):
|
||||
monkeypatch.delenv(key, raising=False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_env(monkeypatch):
|
||||
"""Set up a minimal valid Matrix environment."""
|
||||
monkeypatch.setenv("MATRIX_HOMESERVER", "https://matrix.example.org")
|
||||
monkeypatch.setenv("MATRIX_ACCESS_TOKEN", "syt_test_token_abc123")
|
||||
monkeypatch.setenv("MATRIX_USER_ID", "@bot:example.org")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_urlopen():
|
||||
"""Mock urllib.request.urlopen for HTTP testing."""
|
||||
with patch("urllib.request.urlopen") as mock:
|
||||
yield mock
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_request():
|
||||
"""Mock urllib.request.Request for HTTP testing."""
|
||||
with patch("urllib.request.Request") as mock:
|
||||
yield mock
|
||||
Reference in New Issue
Block a user