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
|