示例#1
0
 def validate_dimensions(width, height):
     if not width and not height:
         raise DimensionsError("Missing dimensions")
     elif width and not str(width).isdigit():
         raise DimensionsError("Invalid width: %s" % width)
     elif height and not str(height).isdigit():
         raise DimensionsError("Invalid height: %s" % height)
示例#2
0
 def test_invalid_width(self):
     qs = urlencode(dict(url="http://foo.co/x.jpg", w="a", h=1))
     resp = self.fetch_error(400, "/?%s" % qs)
     self.assertEqual(resp.get("error_code"), DimensionsError.get_code())
示例#3
0
 def test_invalid_height(self):
     qs = urlencode(dict(url="http://foo.co/x.jpg", w=1, h="a"))
     resp = self.fetch_error(400, "/?%s" % qs)
     self.assertEqual(resp.get("error_code"), DimensionsError.get_code())
示例#4
0
 def test_missing_dimensions(self):
     qs = urlencode(dict(url="http://foo.co/x.jpg"))
     resp = self.fetch_error(400, "/?%s" % qs)
     self.assertEqual(resp.get("error_code"), DimensionsError.get_code())
示例#5
0
 def test_missing_dimensions(self):
     qs = urlencode(dict(url="http://foo.co/x.jpg"))
     resp = self.fetch_error(400, "/?%s" % qs)
     self.assertEqual(resp.get("error_code"), DimensionsError.get_code())