summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2019-01-14 08:56:50 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2019-01-14 08:57:02 (GMT)
commita35727acc1595e067b4327e55128d99d87a9330f (patch)
tree0da4e0a258012e4d218317bfcb3aa45098a195ac
parent2e58ce9b020003a7e1e5f0a6494aafd6600b2514 (diff)
downloadcombo-a35727acc1595e067b4327e55128d99d87a9330f.zip
combo-a35727acc1595e067b4327e55128d99d87a9330f.tar.gz
combo-a35727acc1595e067b4327e55128d99d87a9330f.tar.bz2
tests: always clean media files
-rw-r--r--tests/conftest.py14
-rw-r--r--tests/test_manager.py12
2 files changed, 15 insertions, 11 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 0512eca..2e4e6b5 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,12 +1,24 @@
+import os
+import shutil
+
import pytest
from django.contrib.auth.models import User
+from django.core.files.storage import default_storage
import django_webtest
@pytest.fixture
-def app(request):
+def clean_media():
+ for path in ('uploads', 'assets', 'page-pictures', 'pwa'):
+ if os.path.exists(default_storage.path(path)):
+ shutil.rmtree(default_storage.path(path))
+ return None
+
+
+@pytest.fixture
+def app(request, clean_media):
wtm = django_webtest.WebTestMixin()
wtm._patch_settings()
request.addfinalizer(wtm._unpatch_settings)
diff --git a/tests/test_manager.py b/tests/test_manager.py
index 3c2c359..a864d83 100644
--- a/tests/test_manager.py
+++ b/tests/test_manager.py
@@ -2,7 +2,6 @@ import base64
import json
import os
import re
-import shutil
import mock
@@ -30,12 +29,6 @@ pytestmark = pytest.mark.django_db
TESTS_DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
-@pytest.fixture
-def clean_media():
- for path in ('uploads', 'assets'):
- if os.path.exists(default_storage.path(path)):
- shutil.rmtree(default_storage.path(path))
- return None
def login(app, username='admin', password='admin'):
login_page = app.get('/login/')
@@ -742,11 +735,10 @@ def test_asset_management_anchor(app, admin_user):
# delete
resp = resp.click(href=re.compile('delete.*test.png'))
resp = resp.form.submit()
- assert resp.location.endswith('?page=3')
resp = resp.follow()
assert 'test.png' not in resp.text
-def test_asset_management_search(app, admin_user, clean_media):
+def test_asset_management_search(app, admin_user):
app = login(app)
filepath = os.path.join(settings.CKEDITOR_UPLOAD_PATH, 'test.png')
@@ -767,7 +759,7 @@ def test_asset_management_search(app, admin_user, clean_media):
resp = resp.form.submit()
assert resp.text.count('<tr class="asset') == 2
-def test_asset_slots_management(app, admin_user, clean_media):
+def test_asset_slots_management(app, admin_user):
app = login(app)
assert Asset.objects.count() == 0