integrate/app/consumer/wekan/test_wekan.py

34 lines
1.1 KiB
Python
Raw Permalink Normal View History

2022-04-22 18:34:48 +02:00
import requests
2022-04-29 14:56:51 +02:00
from app.consumer.wekan.models import User, UserBase
from app.consumer.wekan.settings import WekanSettings
2022-04-29 14:13:54 +02:00
from .api import WekanApi
2022-03-03 16:36:08 +01:00
import pytest
2022-04-29 14:56:51 +02:00
@pytest.fixture()
def settings() -> WekanSettings:
return WekanSettings(baseurl="http://localhost:3000", user="api", password="foobar123")
2022-03-03 16:36:08 +01:00
@pytest.fixture
2022-04-29 14:56:51 +02:00
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)
2022-03-06 15:29:00 +01:00
2022-03-03 16:36:08 +01:00
2022-04-29 14:13:54 +02:00
def test_get_user(api: WekanApi):
2022-03-03 16:36:08 +01:00
user = api.get_user("api")
assert user.username == "api"
assert type(user) == User
user = api.get_user("doesnotexist")
assert user == None
2022-04-29 14:13:54 +02:00
def test_get_users(api: WekanApi):
2022-03-03 16:36:08 +01:00
assert True if "api" in [u.username for u in api.get_all_users()] else False
2022-04-29 16:43:47 +02:00
def test_create_and_delete_user(api: WekanApi):
user = api.create_user("foo", "foo42@bar.com", "")
2022-03-03 16:36:08 +01:00
assert api.get_user("foo").username == "foo"
assert type(user) is User
2022-04-29 16:43:47 +02:00
api.delete_user(user.id)
assert api.get_user("foo") == None