48 lines
1.0 KiB
Python
48 lines
1.0 KiB
Python
import pytest
|
|
from httmock import urlmatch, HTTMock, response, remember_called
|
|
|
|
import django_webtest
|
|
|
|
from django.core.files import File
|
|
from django.core.cache import cache
|
|
from django.utils import six
|
|
from io import BytesIO
|
|
|
|
from utils import make_resource
|
|
|
|
if six.PY2:
|
|
collect_ignore = ['wcs/']
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def media(settings, tmpdir):
|
|
settings.MEDIA_ROOT = str(tmpdir.mkdir('media'))
|
|
|
|
|
|
@pytest.fixture
|
|
def app(request):
|
|
wtm = django_webtest.WebTestMixin()
|
|
wtm._patch_settings()
|
|
request.addfinalizer(wtm._unpatch_settings)
|
|
cache.clear()
|
|
return django_webtest.DjangoTestApp()
|
|
|
|
|
|
@pytest.fixture
|
|
def endpoint_dummy_cache(monkeypatch):
|
|
from django.core.cache import caches
|
|
import passerelle.views
|
|
monkeypatch.setattr(
|
|
passerelle.views, 'cache', caches['dummy'])
|
|
|
|
|
|
@urlmatch()
|
|
def internal_server_error(url, request):
|
|
return response(500, 'Internal server error')
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_500():
|
|
with HTTMock(internal_server_error):
|
|
yield None
|