def bake(imageFile, assertion_json_string): """ Embeds a serialized representation of a badge instance in an image file. """ image_type = check_image_type(imageFile) imageFile.seek(0) # reset pointer to the beginning of the file if image_type == 'PNG': return png_bakery.bake(imageFile, assertion_json_string) elif image_type == 'SVG': raise NotImplementedError("SVG BAKING COMING SOON.")
def test_bake_png(self): with open(os.path.join(os.path.dirname(__file__), 'testfiles', 'public_domain_heart.png' )) as image: return_file = png_bakery.bake(image, json.dumps(test_assertion)) return_file.open('r') self.assertEqual(utils.check_image_type(return_file), 'PNG') return_file.close() return_file.open('r') self.assertEqual(png_bakery.unbake(return_file), json.dumps(test_assertion))