The Forgejo Actions CI `test` job has never passed — all 24 runs show failure. Two root causes: the Forgejo `podman` runner's service container networking doesn't reliably expose the PostgreSQL hostname, and the CI pipeline doesn't provision RabbitMQ, causing `fedora_messaging.api.publish()` to raise `ConnectionException`. Since the codebase uses zero PostgreSQL-specific features, the test database backend can safely be switched to SQLite in-memory. This eliminates all external service dependencies for tests. Changes to test infrastructure: - Override `DATABASES` in `tsting.py` to use SQLite in-memory - Add Celery memory broker settings to prevent Redis connections - Add `CRISPY_ALLOWED_TEMPLATE_PACKS` for `bootstrap5` compatibility - Set dummy `ADMIN_USERNAME`/`ADMIN_PASSWORD` for FAS `AccountSystem` - Create `conftest.py` with autouse fixtures to mock `publish()`, `AccountSystem.people_query()`, and provide a stub `STATIC_ROOT` Changes to CI pipeline: - Remove `postgres:15` and `redis:7` service containers - Remove `gcc`/`libpq-dev` system dependency step Bug fixes surfaced by the new test environment: - Replace stale `import ckeditor.fields` in migration 0007 with `models.TextField` (old `django-ckeditor` removed in Phase 5) - Pass `link_rel=None` to `nh3.clean()` to fix `ValueError` when `'rel'` is in `allowed_attributes` (nh3 >= 0.2.18 API change) Closes #281. Assisted-by: Claude Opus 4.6 (1M context) Signed-off-by: Justin Wheeler <jwheel@fedoraproject.org>
36 lines
1 KiB
Python
36 lines
1 KiB
Python
import tempfile
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
from django.test import override_settings
|
|
|
|
MINIMAL_PNG = (
|
|
b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01'
|
|
b'\x00\x00\x00\x01\x08\x02\x00\x00\x00\x90wS\xde\x00'
|
|
b'\x00\x00\x0cIDATx\x9cc\xf8\x0f\x00\x00\x01\x01\x00'
|
|
b'\x05\x18\xd8N\x00\x00\x00\x00IEND\xaeB`\x82'
|
|
)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _mock_fedora_messaging_publish():
|
|
with patch('happinesspackets.messaging.views.publish'):
|
|
yield
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _mock_fas_people_query():
|
|
from fedora.client.fas2 import AccountSystem
|
|
with patch.object(AccountSystem, 'people_query', return_value=[]):
|
|
yield
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _mock_static_root_for_email():
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
images_dir = Path(tmpdir) / 'images'
|
|
images_dir.mkdir()
|
|
(images_dir / 'logo.svg').write_bytes(MINIMAL_PNG)
|
|
with override_settings(STATIC_ROOT=Path(tmpdir)):
|
|
yield
|