Ejemplo n.º 1
0
 def test02_parse_region_bad(self):
     r = IIIFRequest(api_version="1.1")
     r.region = "pct:0,0,50,1000"
     self.assertRaises(IIIFError, r.parse_region)
     r.region = "pct:-10,0,50,100"
     self.assertRaises(IIIFError, r.parse_region)
     r.region = "square"
     self.assertRaises(IIIFError, r.parse_region)
Ejemplo n.º 2
0
 def test02_parse_region_bad(self):
     r = IIIFRequest()
     r.region='pct:0,0,50,1000'
     self.assertRaises( IIIFError, r.parse_region )
     r.region='pct:-10,0,50,100'
     self.assertRaises( IIIFError, r.parse_region )
     r.region='square'
     self.assertRaises( IIIFError, r.parse_region )
Ejemplo n.º 3
0
 def test02_parse_region_bad(self):
     """Bad regions."""
     r = IIIFRequest(api_version='2.0')
     r.region = 'pct:0,0,50,1000'
     self.assertRaises(IIIFError, r.parse_region)
     r.region = 'pct:-10,0,50,100'
     self.assertRaises(IIIFError, r.parse_region)
     r.region = 'square'
     self.assertRaises(IIIFError, r.parse_region)
Ejemplo n.º 4
0
 def test02_parse_region_bad(self):
     """Bad regions."""
     r = IIIFRequest(api_version='2.0')
     r.region = 'pct:0,0,50,1000'
     self.assertRaises(IIIFError, r.parse_region)
     r.region = 'pct:-10,0,50,100'
     self.assertRaises(IIIFError, r.parse_region)
     r.region = 'square'
     self.assertRaises(IIIFError, r.parse_region)
Ejemplo n.º 5
0
 def test01_parse_region(self):
     """Parse region."""
     r = IIIFRequest(api_version='2.1')
     r.region = None
     r.parse_region()
     self.assertTrue(r.region_full)
     r.region = 'full'
     r.parse_region()
     self.assertTrue(r.region_full)
     self.assertFalse(r.region_square)
     r.region = 'square'
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertTrue(r.region_square)
     r.region = '0,1,90,100'
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertFalse(r.region_pct)
     self.assertEqual(r.region_xywh, [0, 1, 90, 100])
     r.region = 'pct:2,3,91,99'
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertTrue(r.region_pct)
     self.assertEqual(r.region_xywh, [2, 3, 91, 99])
     r.region = 'pct:10,10,50,50'
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertTrue(r.region_pct)
     self.assertEqual(r.region_xywh, [10.0, 10.0, 50.0, 50.0])
     r.region = 'pct:0,0,100,100'
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertTrue(r.region_pct)
     self.assertEqual(r.region_xywh, [0.0, 0.0, 100.0, 100.0])
Ejemplo n.º 6
0
 def test01_parse_region(self):
     r = IIIFRequest()
     r.region=None
     r.parse_region()
     self.assertTrue(r.region_full)
     r.region='full'
     r.parse_region()
     self.assertTrue(r.region_full)
     r.region='0,1,90,100'
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertFalse(r.region_pct)
     self.assertEqual(r.region_xywh, [0,1,90,100] )
     r.region='pct:2,3,91,99'
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertTrue(r.region_pct)
     self.assertEqual(r.region_xywh, [2,3,91,99] )
     r.region='pct:10,10,50,50'
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertTrue(r.region_pct)
     self.assertEqual(r.region_xywh, [10.0,10.0,50.0,50.0])
     r.region='pct:0,0,100,100'
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertTrue(r.region_pct)
     self.assertEqual(r.region_xywh, [0.0,0.0,100.0,100.0])
Ejemplo n.º 7
0
 def test01_parse_region(self):
     """Region."""
     r = IIIFRequest(api_version="1.0")
     r.region = None
     r.parse_region()
     self.assertTrue(r.region_full)
     r.region = "full"
     r.parse_region()
     self.assertTrue(r.region_full)
     r.region = "0,1,90,100"
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertFalse(r.region_pct)
     self.assertEqual(r.region_xywh, [0, 1, 90, 100])
     r.region = "pct:2,3,91,99"
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertTrue(r.region_pct)
     self.assertEqual(r.region_xywh, [2, 3, 91, 99])
     r.region = "pct:10,10,50,50"
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertTrue(r.region_pct)
     self.assertEqual(r.region_xywh, [10.0, 10.0, 50.0, 50.0])
     r.region = "pct:0,0,100,100"
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertTrue(r.region_pct)
     self.assertEqual(r.region_xywh, [0.0, 0.0, 100.0, 100.0])
Ejemplo n.º 8
0
 def test01_parse_region(self):
     r = IIIFRequest()
     r.region=None
     r.parse_region()
     self.assertTrue(r.region_full)
     r.region='full'
     r.parse_region()
     self.assertTrue(r.region_full)
     r.region='0,1,90,100'
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertFalse(r.region_pct)
     self.assertEqual(r.region_xywh, [0,1,90,100] )
     r.region='pct:2,3,91,99'
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertTrue(r.region_pct)
     self.assertEqual(r.region_xywh, [2,3,91,99] )
     r.region='pct:10,10,50,50'
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertTrue(r.region_pct)
     self.assertEqual(r.region_xywh, [10.0,10.0,50.0,50.0])
     r.region='pct:0,0,100,100'
     r.parse_region()
     self.assertFalse(r.region_full)
     self.assertTrue(r.region_pct)
     self.assertEqual(r.region_xywh, [0.0,0.0,100.0,100.0])
Ejemplo n.º 9
0
 def test02_parse_region_bad(self):
     """Parse region."""
     r = IIIFRequest(api_version='2.1')
     r.region = 'pct:0,0,50,1000'
     self.assertRaises(IIIFError, r.parse_region)
     r.region = 'pct:-10,0,50,100'
     self.assertRaises(IIIFError, r.parse_region)
     r.region = 'pct:a,b,c,d'
     self.assertRaises(IIIFError, r.parse_region)
     r.region = 'a,b,c,d'
     self.assertRaises(IIIFError, r.parse_region)
     # zero size
     r.region = '0,0,0,100'
     self.assertRaises(IIIFError, r.parse_region)
     r.region = '0,0,100,0'
     self.assertRaises(IIIFError, r.parse_region)
     # bad  name
     r.region = '!square'
     self.assertRaises(IIIFError, r.parse_region)
     r.region = 'square!'
     self.assertRaises(IIIFError, r.parse_region)
     r.region = ''
     self.assertRaises(IIIFError, r.parse_region)
Ejemplo n.º 10
0
 def test03_str(self):
     """Simple tests of str() method."""
     r = IIIFRequest()
     r.baseurl = 'http://ex.org/'
     r.identifier = 'abc'
     # info
     r.info = True
     r.format = 'json'
     self.assertTrue(re.search(r'INFO request', str(r)))
     self.assertTrue(re.search(r'format=json', str(r)))
     # non-info
     r.info = False
     r.region = 'R'
     r.size = 'S'
     r.rotation = 'X'
     r.quality = 'Q'
     r.format = 'jpg'
     self.assertFalse(re.search(r'INFO request', str(r)))
     self.assertTrue(re.search(r'region=R', str(r)))
     self.assertTrue(re.search(r'format=jpg', str(r)))
Ejemplo n.º 11
0
 def test03_str(self):
     """Simple tests of str() method."""
     r = IIIFRequest()
     r.baseurl = 'http://ex.org/'
     r.identifier = 'abc'
     # info
     r.info = True
     r.format = 'json'
     self.assertTrue(re.search(r'INFO request', str(r)))
     self.assertTrue(re.search(r'format=json', str(r)))
     # non-info
     r.info = False
     r.region = 'R'
     r.size = 'S'
     r.rotation = 'X'
     r.quality = 'Q'
     r.format = 'jpg'
     self.assertFalse(re.search(r'INFO request', str(r)))
     self.assertTrue(re.search(r'region=R', str(r)))
     self.assertTrue(re.search(r'format=jpg', str(r)))
Ejemplo n.º 12
0
 def test02_parse_region_bad(self):
     r = IIIFRequest()
     r.region='pct:0,0,50,1000'
     self.assertRaises( IIIFError, r.parse_region )
     r.region='pct:-10,0,50,100'
     self.assertRaises( IIIFError, r.parse_region )
     r.region='pct:a,b,c,d'
     self.assertRaises( IIIFError, r.parse_region )
     r.region='a,b,c,d'
     self.assertRaises( IIIFError, r.parse_region )
     # zero size
     r.region='0,0,0,100'
     self.assertRaises( IIIFError, r.parse_region )
     r.region='0,0,100,0'
     self.assertRaises( IIIFError, r.parse_region )
Ejemplo n.º 13
0
 def test02_parse_region_bad(self):
     r = IIIFRequest(api_version='1.1')
     r.region='pct:0,0,50,1000'
     self.assertRaises( IIIFError, r.parse_region )
     r.region='pct:-10,0,50,100'
     self.assertRaises( IIIFError, r.parse_region )
Ejemplo n.º 14
0
 def test02_parse_region_bad(self):
     r = IIIFRequest(api_version='1.1')
     r.region = 'pct:0,0,50,1000'
     self.assertRaises(IIIFError, r.parse_region)
     r.region = 'pct:-10,0,50,100'
     self.assertRaises(IIIFError, r.parse_region)