More refactoring
This commit is contained in:
39
tests/test_learnables.py
Normal file
39
tests/test_learnables.py
Normal 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
|
||||
Reference in New Issue
Block a user