def test_img_size(self): path = '/%s/full/full/0/default.jpg' % self.test_jp2_color_id req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, u'image') self.assertEqual(loris_request.params['size'], 'full') path = '/%s/full/max/0/default.jpg' % self.test_jp2_color_id req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, u'image') self.assertEqual(loris_request.params['size'], 'max') path = '/%s/full/150,/0/default.jpg' % self.test_jp2_color_id req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, u'image') self.assertEqual(loris_request.params['size'], '150,') path = '/%s/full/pct:50/0/default.jpg' % self.test_jp2_color_id req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, u'image') self.assertEqual(loris_request.params['size'], 'pct:50') path = '/%s/full/!225,100/0/default.jpg' % self.test_jp2_color_id req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, u'image') self.assertEqual(loris_request.params['size'], '!225,100')
def test_img_quality(self): path = '/%s/full/full/0/gray.jpg' % (self.test_jp2_color_id, ) req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, 'image') self.assertEqual(loris_request.params['quality'], 'gray') path = '/%s/full/full/0/native.jpg' % (self.test_jp2_color_id, ) req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, u'bad_image_request')
def test_template_delimiter_request(self): identifier = 'a:foo|bar' #image request path = f'/{identifier}/full/full/0/default.jpg' req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req) self.assertEqual(loris_request.request_type, 'image') self.assertEqual(loris_request.ident, identifier) #info request path = f'/{identifier}/info.json' req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req) self.assertEqual(loris_request.request_type, 'info') self.assertEqual(loris_request.ident, identifier)
def test_template_delimiter_request(self): identifier = u'a:foo|bar' encoded_identifier = u'a%3Afoo%7Cbar' #image request path = u'/%s/full/full/0/default.jpg' % identifier req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req) self.assertEqual(loris_request.request_type, u'image') self.assertEqual(loris_request.ident, encoded_identifier) #info request path = u'/%s/info.json' % identifier req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req) self.assertEqual(loris_request.request_type, u'info') self.assertEqual(loris_request.ident, encoded_identifier)
def test_many_slash_info_request(self): identifier = '1/2/3/4/5/6/7/8/9/xyz' path = f'/{identifier}/info.json' req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, 'info') self.assertEqual(loris_request.ident, identifier)
def test_info_request(self): info_path = '/%s/info.json' % self.test_jp2_color_id req = _get_werkzeug_request(info_path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.ident, self.test_jp2_color_id) self.assertEqual(loris_request.params, 'info.json') self.assertEqual(loris_request.request_type, 'info')
def test_favicon(self): path = '/favicon.ico' req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.ident, '') self.assertEqual(loris_request.params, '') self.assertEqual(loris_request.request_type, 'favicon')
def test_unescaped_ident_request(self): path = '/01/02/0001.jp2/' req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, True, None) self.assertEqual(loris_request.ident, '01%2F02%2F0001.jp2') self.assertEqual(loris_request.params, '') self.assertEqual(loris_request.request_type, 'redirect_info')
def test_get_base_uri_proxy_path(self): path = '/%s/' % self.test_jp2_color_id req = _get_werkzeug_request(path) proxy_path = 'http://example.org/' loris_request = webapp.LorisRequest(req, True, proxy_path) self.assertEqual(loris_request.base_uri, 'http://example.org/01%2F02%2F0001.jp2')
def test_root_path(self): path = '/' req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.ident, '') self.assertEqual(loris_request.params, '') self.assertEqual(loris_request.request_type, 'index')
def test_info_request(self): info_path = f'/{self.test_jp2_color_id}/info.json' req = _get_werkzeug_request(info_path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.ident, '01/02/0001.jp2') self.assertEqual(loris_request.params, 'info.json') self.assertEqual(loris_request.request_type, 'info')
def test_img_rotation(self): path = '/%s/full/full/0/default.jpg' % self.test_jp2_color_id req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, u'image') self.assertEqual(loris_request.params['rotation'], '0') path = '/%s/full/full/22.5/default.jpg' % self.test_jp2_color_id req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, u'image') self.assertEqual(loris_request.params['rotation'], '22.5') path = '/%s/full/full/!0/default.jpg' % self.test_jp2_color_id req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, u'image') self.assertEqual(loris_request.params['rotation'], '!0')
def test_img_region(self): path = '/%s/square/full/0/default.jpg' % self.test_jp2_color_id req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, u'image') self.assertEqual(loris_request.params['region'], 'square') path = '/%s/0,0,500,500/full/0/default.jpg' % self.test_jp2_color_id req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, u'image') self.assertEqual(loris_request.params['region'], '0,0,500,500') path = '/%s/pct:41.6,7.5,40,70/full/0/default.jpg' % self.test_jp2_color_id req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, u'image') self.assertEqual(loris_request.params['region'], 'pct:41.6,7.5,40,70')
def test_ident_request(self): path = '/%s/' % self.test_jp2_color_id req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, True, None) self.assertEqual(loris_request.ident, self.test_jp2_color_id) self.assertEqual(loris_request.params, '') self.assertEqual(loris_request.request_type, 'redirect_info')
def test_many_slash_info_request(self): identifier = '1/2/3/4/5/6/7/8/9/xyz' encoded_identifier = '1%2F2%2F3%2F4%2F5%2F6%2F7%2F8%2F9%2Fxyz' path = '/%s/info.json' % identifier req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, u'info') self.assertEqual(loris_request.ident, encoded_identifier)
def test_img_request(self): path = '/%s/full/full/0/default.jpg' % self.test_jp2_color_id req = self._get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.ident, self.test_jp2_color_id) expected_params = {'region': u'full', 'size': u'full', 'rotation': u'0', 'quality': u'default', 'format': u'jpg'} self.assertEqual(loris_request.params, expected_params) self.assertEqual(loris_request.request_type, u'image')
def test_https_uri_identifier(self): identifier = 'https://sample.sample/0001' encoded_identifier = 'https%3A%2F%2Fsample.sample%2F0001' path = '/%s/full/full/0/default.jpg' % identifier req = self._get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.ident, encoded_identifier) expected_params = {'region': u'full', 'size': u'full', 'rotation': u'0', 'quality': u'default', 'format': u'jpg'} self.assertEqual(loris_request.params, expected_params) self.assertEqual(loris_request.request_type, u'image')
def test_many_slash_img_request(self): identifier = '1/2/3/4/5/6/7/8/9/xyz' encoded_identifier = '1%2F2%2F3%2F4%2F5%2F6%2F7%2F8%2F9%2Fxyz' path = '/%s/full/full/0/default.jpg' % identifier req = self._get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.ident, encoded_identifier) expected_params = {'region': u'full', 'size': u'full', 'rotation': u'0', 'quality': u'default', 'format': u'jpg'} self.assertEqual(loris_request.params, expected_params) self.assertEqual(loris_request.request_type, u'image')
def test_img_request(self): path = f'/{self.test_jp2_color_id}/full/full/0/default.jpg' req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.ident, '01/02/0001.jp2') expected_params = { 'region': 'full', 'size': 'full', 'rotation': '0', 'quality': 'default', 'format': 'jpg' } self.assertEqual(loris_request.params, expected_params) self.assertEqual(loris_request.request_type, 'image')
def test_get_base_uri(self): path = '/%s/' % self.test_jp2_color_id req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, True, None) self.assertEqual(loris_request.base_uri, 'http://localhost/01%2F02%2F0001.jp2')
def test_ident_request_no_redirect(self): path = '/%s/' % self.test_jp2_color_id req = self._get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.ident, self.test_jp2_color_id + '%2F') self.assertEqual(loris_request.request_type, 'redirect_info')
def test_ident_request_no_redirect(self): path = f'/{self.test_jp2_color_id}/' req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.ident, '01/02/0001.jp2/') self.assertEqual(loris_request.request_type, 'redirect_info')
def test_img_format(self): path = '/%s/full/full/0/default.jpg' % (self.test_jp2_color_id, ) req = _get_werkzeug_request(path) loris_request = webapp.LorisRequest(req, False, None) self.assertEqual(loris_request.request_type, 'image') self.assertEqual(loris_request.params['format'], 'jpg')