37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
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@bar.com", "")
|
|
assert api.get_user("foo").username == "foo"
|
|
assert type(user) is User
|
|
|
|
def test_delete_user(api: WekanApi):
|
|
api.create_user("foo", "foo@bar.com", "")
|
|
api.delete_user("foo") # TODO: doesn't work?
|
|
pytest.skip("smth wrong with wekan api")
|
|
assert api.get_user("foo") == None
|