import requests from app.consumer.wekan.models import User, UserBase from app.consumer.wekan.settings import WekanSettings from .api import WekanApi import pytest @pytest.fixture() def settings() -> WekanSettings: return WekanSettings(baseurl="http://localhost:3000", user="api", password="foobar123") @pytest.fixture def api(settings: WekanSettings) -> WekanApi: r = requests.post("http://localhost:3000/users/register", json={"username": "api", "password": "foobar123", "email": "foo@example.org"}) return WekanApi(settings) def test_get_user(api: WekanApi): user = api.get_user("api") assert user.username == "api" assert type(user) == User user = api.get_user("doesnotexist") assert user == None def test_get_users(api: WekanApi): assert True if "api" in [u.username for u in api.get_all_users()] else False def test_create_user(api: WekanApi): user = api.create_user("foo", "foo@32bar.com", "") assert api.get_user("foo").username == "foo" assert type(user) is User def test_delete_user(api: WekanApi): u = api.create_user("Bar", "foo@bar42.com", "") api.delete_user(u.id) assert api.get_user("Bar") == None