More refactoring

This commit is contained in:
lvrossem
2023-04-18 02:52:26 -06:00
parent d074074b03
commit 3968dfd4eb
10 changed files with 156 additions and 64 deletions

39
tests/test_learnables.py Normal file
View File

@@ -0,0 +1,39 @@
import random
import pytest
from src.enums import CourseEnum
from tests.base import client, get_headers, register_user
from tests.config.database import clear_db
@pytest.mark.asyncio
async def test_create_learnables_should_succeed():
clear_db()
token = await register_user()
headers = get_headers(token)
for course in CourseEnum:
if course != CourseEnum.All:
nr_learnables = random.randint(1, 5)
for i in range(nr_learnables):
response = client.post(
f"/learnables/{course}",
json={
"index": i,
"in_use": bool(random.randint(0, 1)),
"name": f"{course} {i}",
},
headers=headers,
)
assert response.status_code == 200
response = client.get(f"/learnables/{course}", headers=headers)
assert response.status_code == 200
response = response.json()
assert len(response) == nr_learnables