AG

Angelo Gladding
lahacker.net

dlv5vbq7lzlthol5 4b942a3185b37d00

Home CodecanopyFiles

tests.py

5 tests ran in 11 seconds. Tests are failing.

# import pathlib

import canopy


name = "Alice"
passphrase = "alicepassword"
keysize = 1024
host = "alice.dev.cnpy.gdn"


def setup_module(module):
    canopy.delete_host(host)
    canopy.setup_host(name, passphrase, keysize, host)


def test_setup():
    # represents module setup
    assert True


def test_owner_details():
    """assert the owner's contact details have been created"""
    resource = canopy.content.read.get_resource("contact", "me")
    print(resource)
    assert resource["name"] == name


# def test_failure():
#     assert False


def test_create_note():
    """assert a note has been created"""
    body = "Hello world!"
    resource_id = canopy.content.write.quick_draft("note", {"body": body},
                                                   publish=True)
    resource = canopy.content.read.get_resource_by_id(resource_id)
    assert resource["body"] == body


def test_upload_photo():
    """"""
    with (data_dir / "alice.jpg").open("rb") as fp:
        data = {"image": fp.read()}
    resource_id = canopy.content.write.quick_draft("image", data, publish=True)
    resource = canopy.content.read.get_resource_by_id(resource_id)
    assert "images" in resource
    # TODO find and assign face to identity
    # TODO update photo in profile


# characters = {}
# data_dir = pathlib.Path(__file__).parent / "data"


# def mock():
#    def note(identity, body, tags, license, datetime):
#        n = dict(body=body, tags=tags.split(","), license=license)
#        published = pendulum.strptime(datetime, "%Y-%m-%d %H:%M:%S")
#        web.tx.db = canopy.get_db("testing.{}.lahacker.net".format(identity))
#        canopy.__web__.feed.create_note(n, published)
#    note("alice", "Happy new year! Wish everyone a healthy and "
#         "fulfilling future", "holiday", "cc-zero", "2017-01-01 00:00:00")
#    note("alice", "Happy vernal equinox! Time to prep your plots!",
#         "seasons", "cc-by", "2017-03-20 10:28:00")
#    note("bob", "Washed the dog!", "seasons", "cc-by", "2017-04-03 02:19:12")