Exemple #1
0
    def test_old_symlink_is_replaced(self, symlink_src, tmpdir):
        # Create the dst, and write some text into it
        dst = str(tmpdir.join('foo'))
        open(dst, 'wb').write(b'I am the old file')

        # Now create a symlink to dst, and check it's become a symlink, and
        # the old contents are gone
        utils.symlink(symlink_src, dst)
        self._assert_is_symlink(symlink_src, dst)
        assert open(dst, 'wb') != b'I am the old file'
Exemple #2
0
 def store(self, image_request, image_info, canonical_fp):
     # Because we're working with files, it's more practical to put derived
     # images where the cache expects them when they are created (i.e. by
     # Loris#_make_image()), so __setitem__, as defined by the dict API
     # doesn't really work. Instead, the logic related to where an image
     # should be put is encapulated in the ImageCache#get_request_cache_path
     # and ImageCache#get_canonical_cache_path methods.
     #
     # Instead, __setitem__ simply makes a symlink in the cache from the
     # requested syntax to the canonical syntax to enable faster lookups of
     # the same non-canonical request the next time.
     #
     # So: when Loris#_make_image is called, it gets a path from
     # ImageCache#get_canonical_cache_path and passes that to the
     # transformer.
     if not image_request.is_canonical(image_info):
         requested_fp = self.get_request_cache_path(image_request)
         symlink(src=canonical_fp, dst=requested_fp)
Exemple #3
0
 def test_creates_symlink(self, symlink_src, tmpdir):
     dst = str(tmpdir.join('foo'))
     utils.symlink(symlink_src, dst)
     self._assert_is_symlink(symlink_src, dst)
Exemple #4
0
 def test_circular_symlink_is_ignored(self, symlink_src):
     utils.symlink(symlink_src, symlink_src)
     assert os.path.isfile(symlink_src)
Exemple #5
0
 def test_creates_intermediate_directories(self, symlink_src, tmpdir):
     dst = str(tmpdir.join('foo/bar/baz'))
     utils.symlink(symlink_src, dst)
     self._assert_is_symlink(symlink_src, dst)