import pathlib

current = pathlib.Path(__file__).parent
root = current.parent

import sys
sys.path.append(str(root))

import assets

import base64

test = pathlib.Path("./test")
test.mkdir()

sample_product = assets.product()
sample_product.name = "sample"

print("Create sample directory.")
sample = assets.directory_image(test)

print("Opening sample file.")
with open("sample.png", "rb") as sample_file:
    sample_image_content = base64.b64encode(sample_file.read())
    sample_image = assets.image(sample_image_content)

print()

print("Save it.")
sample.save(sample_image, sample_product)
print()

input("Prese enter after validate:")
print("Move files...")

sample_product_sec = assets.product()
sample_product_sec.name = "sample 2"
sample.update(sample_product, sample_product_sec)
print()

input("Prese enter after validate:")
print("Remove files...")

sample.drop(sample_product_sec)

test.rmdir()
