Exemplo n.º 1
0
 def test_generate_signature(self):
     """ Generating hash signature"""
     filename = 'example.jpg'
     id = utils.generate_id('jpg')
     pb = PathBuilder('12345')
     signature1 = pb.generate_signature(id, filename)
     signature2 = pb.generate_signature(id, filename)
     self.assertEquals(signature1, signature2)
Exemplo n.º 2
0
 def test_resize_filename_parser_raises_on_bad_quality(self):
     """ Resize filename parser raises if target size invalid """
     id = utils.generate_id('test.jpg')
     params = dict(size='100x200',
                   factor='100x200',
                   format='jpg',
                   upscale='upscale',
                   quality='VRAP')
     pb = PathBuilder('12345')
     schema = '{size}-{factor}-{quality}-{upscale}.{format}'
     signed_schema = '{size}-{factor}-{quality}-{upscale}-{sig}.{format}'
     params['sig'] = pb.generate_signature(id, schema.format(**params))
     signed_filename = signed_schema.format(**params)
     with assert_raises(x.InvalidArgumentException):
         pb.filename_to_resize_params(id, signed_filename)