Ejemplo n.º 1
0
 def test_img_to_buf_source(self):
     img = new("RGB", (256, 256), "red")
     img.save("test2.jpg")
     img.format = "JPEG"
     data = img_to_buf(img, 'source').read()
     # a 'JFIF' chunk in the bitstream indicates a .jpg image
     assert 'JFIF' in data
Ejemplo n.º 2
0
 def test_img_to_buf_png(self):
     img = new("RGB", (256, 256), "red")
     img.save("test1.png", 'PNG')
     data = img_to_buf(img, 'png').read()
     # ImageHeaDeR, ImageDATa, and ImageEND are
     # all necessary chunks in a .PNG bitstream
     assert 'IHDR' in data and 'IDAT' in data and 'IEND' in data
Ejemplo n.º 3
0
 def test_insert_image_blob(self):
     img = new("RGB", (256, 256), "red")
     data = img_to_buf(img, 'jpeg').read()
     tempDB = self.__make_tempDB()
     tempDB.insert_image_blob(0, 0, 0, Binary(data))
     result = tempDB.cursor.execute("select count(*) from tiles;")
     assert result.fetchone()[0] == 1
Ejemplo n.º 4
0
def test_combine_worker_dbs():
    session_folder = make_session_folder()
    # make a random number of tempdbs with dummy data
    img = new("RGB", (256, 256), "red")
    data = img_to_buf(img, 'jpeg').read()
    z = randint(2, 5)
    for x in xrange(z):
        TempDB(session_folder).insert_image_blob(x, 0, 0, Binary(data))
    # confirm that combine_worker_dbs assimilates all tempdb's into gpkg
    chdir(session_folder) # necessary to put gpkg in session_folder
    gpkg = Geopackage("test.gpkg", 4326)
    combine_worker_dbs(gpkg)
    result = gpkg.execute("select count(*) from tiles;")
    assert (result.fetchone())[0] == z
Ejemplo n.º 5
0
 def test_img_to_buf_jpg(self):
     img = new("RGB", (256, 256), "red")
     data = img_to_buf(img, 'jpeg').read()
     # a 'JFIF' chunk in the bitstream indicates a .jpg image
     assert 'JFIF' in data