fix test format

This commit is contained in:
Julien Aldon
2026-03-02 16:33:52 +01:00
parent 5dd9e19877
commit 0e48d1bbaa
20 changed files with 751 additions and 436 deletions

View File

@@ -6,30 +6,37 @@ import src.forms.service as forms_service
import src.forms.exceptions as forms_exceptions
import tests.factories.forms as forms_factory
class TestFormsService:
def test_get_all_forms(self, session: Session, forms: list[models.FormPublic]):
def test_get_all_forms(self, session: Session,
forms: list[models.FormPublic]):
result = forms_service.get_all(session, [], [], False)
assert len(result) == 2
assert result == forms
def test_get_all_forms_filter_productors(self, session: Session, forms: list[models.FormPublic]):
def test_get_all_forms_filter_productors(
self, session: Session, forms: list[models.FormPublic]):
result = forms_service.get_all(session, [], ['test productor'], False)
assert len(result) == 2
assert result == forms
def test_get_all_forms_filter_season(self, session: Session, forms: list[models.FormPublic]):
def test_get_all_forms_filter_season(
self, session: Session, forms: list[models.FormPublic]):
result = forms_service.get_all(session, ['test season 1'], [], False)
assert len(result) == 1
def test_get_all_forms_all_filters(self, session: Session, forms: list[models.FormPublic]):
result = forms_service.get_all(session, ['test season 1'], ['test productor'], True)
def test_get_all_forms_all_filters(
self, session: Session, forms: list[models.FormPublic]):
result = forms_service.get_all(
session, ['test season 1'], ['test productor'], True)
assert result == forms
def test_get_one_form(self, session: Session, forms: list[models.FormPublic]):
def test_get_one_form(self, session: Session,
forms: list[models.FormPublic]):
result = forms_service.get_one(session, forms[0].id)
assert result == forms[0]
@@ -37,10 +44,10 @@ class TestFormsService:
def test_get_one_form_notfound(self, session: Session):
result = forms_service.get_one(session, 122)
assert result == None
assert result is None
def test_create_form(
self,
self,
session: Session,
productor: models.ProductorPublic,
referer: models.ProductorPublic
@@ -56,10 +63,10 @@ class TestFormsService:
assert result.id is not None
assert result.name == "new test form"
assert result.productor.name == "test productor"
def test_create_form_invalidinput(
self,
session: Session,
self,
session: Session,
productor: models.Productor
):
form_create = None
@@ -69,17 +76,16 @@ class TestFormsService:
form_create = forms_factory.form_create_factory(productor_id=123)
with pytest.raises(forms_exceptions.ProductorNotFoundError):
result = forms_service.create_one(session, form_create)
form_create = forms_factory.form_create_factory(
productor_id=productor.id,
productor_id=productor.id,
referer_id=123
)
with pytest.raises(forms_exceptions.UserNotFoundError):
result = forms_service.create_one(session, form_create)
def test_update_form(
self,
self,
session: Session,
productor: models.ProductorPublic,
referer: models.ProductorPublic,
@@ -97,9 +103,9 @@ class TestFormsService:
assert result.id == form_id
assert result.name == 'updated test form'
assert result.season == 'updated test season'
def test_update_form_notfound(
self,
self,
session: Session,
productor: models.ProductorPublic,
referer: models.ProductorPublic,
@@ -113,42 +119,41 @@ class TestFormsService:
form_id = 123
with pytest.raises(forms_exceptions.FormNotFoundError):
result = forms_service.update_one(session, form_id, form_update)
def test_update_form_invalidinput(
self,
session: Session,
productor: models.ProductorPublic,
self,
session: Session,
productor: models.ProductorPublic,
forms: list[models.FormPublic]
):
form_id = forms[0].id
form_update = forms_factory.form_update_factory(productor_id=123)
with pytest.raises(forms_exceptions.ProductorNotFoundError):
result = forms_service.update_one(session, form_id, form_update)
form_update = forms_factory.form_update_factory(
productor_id=productor.id,
productor_id=productor.id,
referer_id=123
)
with pytest.raises(forms_exceptions.UserNotFoundError):
result = forms_service.update_one(session, form_id, form_update)
def test_delete_form(
self,
session: Session,
self,
session: Session,
forms: list[models.FormPublic]
):
form_id = forms[0].id
result = forms_service.delete_one(session, form_id)
check = forms_service.get_one(session, form_id)
assert check == None
assert check is None
def test_delete_form_notfound(
self,
session: Session,
self,
session: Session,
forms: list[models.FormPublic]
):
form_id = 123
with pytest.raises(forms_exceptions.FormNotFoundError):
result = forms_service.delete_one(session, form_id)