Exemplo n.º 1
0
def resource():
    UserRepo.add_user(username="******",
                      password="******",
                      email="*****@*****.**")
    user_id = UserRepo.get_all_users()[0].id
    yield user_id
    drop_db("gtd_test")  #TODO: Read from config?
Exemplo n.º 2
0
def test_store_user(resource):
    UserRepo.add_user(username="******",
                      password="******",
                      email="*****@*****.**")
    users = UserRepo.get_all_users()
    assert len(users) == 1
    assert users[0].username == "user1"
    assert users[0].email == "*****@*****.**"
    resource
Exemplo n.º 3
0
def test_get_user_by_id(resource):
    UserRepo.add_user(username="******",
                      password="******",
                      email="*****@*****.**")
    users = UserRepo.get_all_users()
    assert len(users) == 1
    uid = users[0].id
    stored_user = UserRepo.get_user_by_id(uid)
    assert stored_user.username == "user1"
    assert stored_user.email == "*****@*****.**"
    not_stored_user = UserRepo.get_user_by_id(
        random_objectid())  #should not be in the database
    assert not_stored_user == None
    resource