import pathlib

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

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

import assets

""" Make sure You have API key and CX in config file. """
""" https://programmablesearchengine.google.com/ """

location = root / pathlib.Path("config.json")
resources = assets.config_loader(assets.app_config).load(location).resources
autoadder = resources.autoadder

print("Questing 5907608646584...")
print(autoadder.find("5907608646584"))
print()

print("Testing app:")

factory = assets.user_factory()
factory.nick = "sample"
factory.password = "password"
user = factory.result

collection = assets.users_collection()
collection.add(user)

app = assets.autoadder_app(collection, resources.autoadder)

print("Questing 5907608646584...")
print(app.find({
    "apikey": user.apikey,
    "barcode": "5907608646584"
}))
print()