Beispiel #1
0
 def validate_options(opts):
     opts = Image._normalize_options(opts)
     if opts["mode"] not in Image.MODES:
         raise ModeError("Invalid mode: %s" % opts["mode"])
     elif opts["filter"] not in Image.FILTERS:
         raise FilterError("Invalid filter: %s" % opts["filter"])
     elif opts["position"] not in Image.POSITIONS:
         raise PositionError("Invalid position: %s" % opts["position"])
     elif not Image._isint(opts["background"], 16) \
             or len(opts["background"]) not in [3, 4, 6, 8]:
         raise BackgroundError("Invalid background: %s" %
                               opts["background"])
     elif not Image._isint(opts["quality"]) \
             or int(opts["quality"]) > 100 or int(opts["quality"]) < 0:
         raise QualityError("Invalid quality: %s", str(opts["quality"]))
Beispiel #2
0
 def test_outofbounds_quality(self):
     qs = urlencode(dict(url="http://foo.co/x.jpg", w=1, h=1, q=200))
     resp = self.fetch_error(400, "/?%s" % qs)
     self.assertEqual(resp.get("error_code"), QualityError.get_code())
Beispiel #3
0
 def test_invalid_integer_quality(self):
     qs = urlencode(dict(url="http://foo.co/x.jpg", w=1, h=1, q="a"))
     resp = self.fetch_error(400, "/?%s" % qs)
     self.assertEqual(resp.get("error_code"), QualityError.get_code())
Beispiel #4
0
 def test_outofbounds_quality(self):
     qs = urlencode(dict(url="http://foo.co/x.jpg", w=1, h=1, q=200))
     resp = self.fetch_error(400, "/?%s" % qs)
     self.assertEqual(resp.get("error_code"), QualityError.get_code())
Beispiel #5
0
 def test_invalid_integer_quality(self):
     qs = urlencode(dict(url="http://foo.co/x.jpg", w=1, h=1, q="a"))
     resp = self.fetch_error(400, "/?%s" % qs)
     self.assertEqual(resp.get("error_code"), QualityError.get_code())