Permalink
Browse files

* don't try to clear the url cache when uploading files to the filer …

…clipboard

* when running the unit tests, clear files generated by each test (don't leave garbage behind)
  • Loading branch information...
1 parent 52796f2 commit 42925d17a098ad701bc25f59237f372d8f44604c @kux kux committed Dec 29, 2012
Showing with 14 additions and 1 deletion.
  1. +2 −0 filertags/signals.py
  2. +12 −1 filertags/tests.py
View
@@ -248,6 +248,8 @@ def update_referencing_css_files(instance, **kwargs):
def clear_urls_cache(instance, **kwargs):
"""Clears urls cached by the filerfile tag. """
+ if _is_in_clipboard(instance):
+ return
logical_file_path = urlparse.urljoin(
_construct_logical_folder_path(instance),
instance.original_filename)
View
@@ -1,29 +1,41 @@
import os.path
import re
+import shutil
from django.core.cache import cache
from django.core.files.base import File as DjangoFile, ContentFile
from django.test import TestCase
from filer.models.filemodels import File
from filer.models.foldermodels import Folder
+from filer.settings import FILER_PUBLICMEDIA_STORAGE
from filer.tests.helpers import create_superuser
from filertags.signals import _ALREADY_PARSED_MARKER, _LOGICAL_URL_TEMPLATE
class CssRewriteTest(TestCase):
+ def _get_test_usermedia_location(self):
+ HERE = os.path.dirname(os.path.realpath(__file__))
+ return os.path.join(HERE, 'tmp_user_media')
+
def setUp(self):
self.superuser = create_superuser()
self.client.login(username='admin', password='secret')
media_folder = Folder.objects.create(name='media')
producer = Folder.objects.create(name='producer', parent=media_folder)
self.producer_css = Folder.objects.create(name='css', parent=producer)
self.producer_images = Folder.objects.create(name='images', parent=producer)
+ self.usual_location = FILER_PUBLICMEDIA_STORAGE.location
+ # all files generated during these tests are written to ./tmp_user_media
+ # and get deleted afterwards (see tearDown)
+ FILER_PUBLICMEDIA_STORAGE.location = self._get_test_usermedia_location()
def tearDown(self):
cache.clear()
+ shutil.rmtree(FILER_PUBLICMEDIA_STORAGE.location)
+ FILER_PUBLICMEDIA_STORAGE.location = self.usual_location
def create_file(self, name, folder, content=None):
if content is None:
@@ -37,7 +49,6 @@ def create_file(self, name, folder, content=None):
file=file_obj,
folder=folder)
-
def test_abslute_url_css_before_image(self):
css = self.create_file('absolute_url_to_image.css', self.producer_css,
content="""\

0 comments on commit 42925d1

Please sign in to comment.