예제 #1
0
파일: resolver_t.py 프로젝트: gpg-dev/loris
 def test_absent_ident_is_unresolvable(self):
     config = {
         'source_root' : '/var/loris/src',
         'cache_root' : '/var/loris/cache'
     }
     resolver = SourceImageCachingResolver(config=config)
     assert not resolver.is_resolvable(ident='doesnotexist.jp2')
예제 #2
0
파일: resolver_t.py 프로젝트: gpg-dev/loris
 def test_present_ident_is_resolvable(self):
     ident = self.test_png_id
     config = {
         'source_root' : join(dirname(realpath(__file__)), 'img'),
         'cache_root' : self.app.img_cache.cache_root
     }
     resolver = SourceImageCachingResolver(config=config)
     assert resolver.is_resolvable(ident=ident)
예제 #3
0
	def test_source_image_caching_resolver(self):
		# First we need to change the resolver on the test instance of the 
		# application (overrides the config to use SimpleFSResolver)
		config = {
			'source_root' : join(dirname(realpath(__file__)), 'img'), 
			'cache_root' : self.app.img_cache.cache_root
		}
		self.app.resolver = SourceImageCachingResolver(config)

		# Now...
		ident = self.test_jp2_color_id
		resolved_path, fmt = self.app.resolver.resolve(ident)
		expected_path = join(self.app.img_cache.cache_root, unquote(ident))

		self.assertEqual(expected_path, resolved_path)
		self.assertEqual(fmt, 'jp2')
		self.assertTrue(isfile(resolved_path))
예제 #4
0
파일: resolver_t.py 프로젝트: gpg-dev/loris
    def test_source_image_caching_resolver(self):
        # First we need to change the resolver on the test instance of the
        # application (overrides the config to use SimpleFSResolver)
        config = {
            'source_root' : join(dirname(realpath(__file__)), 'img'),
            'cache_root' : self.app.img_cache.cache_root
        }
        self.app.resolver = SourceImageCachingResolver(config)

        # Now...
        ident = self.test_jp2_color_id
        ii = self.app.resolver.resolve(self.app, ident, "")
        expected_path = join(self.app.img_cache.cache_root, unquote(ident))

        self.assertEqual(expected_path, ii.src_img_fp)
        self.assertEqual(ii.src_format, 'jp2')
        self.assertTrue(isfile(ii.src_img_fp))

        # Now we resolve it a second time, to test the case where the
        # cache is already warm.
        ii = self.app.resolver.resolve(self.app, ident, base_uri="")
        assert ii.src_img_fp == expected_path
        assert ii.src_format == "jp2"
        assert os.path.isfile(ii.src_img_fp)