2022-03-03 16:36:08 +01:00
|
|
|
from app.wekan.models import User, UserBase
|
|
|
|
from .api import Wekan
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def api() -> Wekan:
|
2022-03-06 15:29:00 +01:00
|
|
|
try:
|
|
|
|
return Wekan("https://board.lit.yksflip.de", "api", "foobar123")
|
|
|
|
except:
|
|
|
|
pytest.skip("API not reachable?")
|
|
|
|
|
2022-03-03 16:36:08 +01:00
|
|
|
|
|
|
|
def test_get_user(api: Wekan):
|
|
|
|
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: Wekan):
|
|
|
|
assert True if "api" in [u.username for u in api.get_all_users()] else False
|
|
|
|
|
|
|
|
def test_create_user(api: Wekan):
|
|
|
|
user = api.create_user("foo", "foo@bar.com", "")
|
|
|
|
assert api.get_user("foo").username == "foo"
|
|
|
|
assert type(user) is User
|
|
|
|
|
|
|
|
def test_delete_user(api: Wekan):
|
|
|
|
api.create_user("foo", "foo@bar.com", "")
|
|
|
|
api.delete_user("foo") # TODO: doesn't work?
|
|
|
|
assert api.get_user("foo") == None
|