|
@@ -76,6 +76,7 @@ async def test_create_volunteer(
|
|
|
assert response.status_code == 200
|
|
assert response.status_code == 200
|
|
|
assert response.json()["id"] != default_project_id
|
|
assert response.json()["id"] != default_project_id
|
|
|
assert response.json()["name"] == "Lancelot"
|
|
assert response.json()["name"] == "Lancelot"
|
|
|
|
|
+ assert response.json()["comment"] == ""
|
|
|
result = session.execute(
|
|
result = session.execute(
|
|
|
select(Volunteer).where(Volunteer.project_id == default_project_id)
|
|
select(Volunteer).where(Volunteer.project_id == default_project_id)
|
|
|
)
|
|
)
|
|
@@ -92,6 +93,35 @@ async def test_create_volunteer(
|
|
|
assert response.status_code == 422
|
|
assert response.status_code == 422
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+async def test_create_volunteer_comment(
|
|
|
|
|
+ client: AsyncClient,
|
|
|
|
|
+ default_public_project: Project,
|
|
|
|
|
+ default_user_headers: dict,
|
|
|
|
|
+ session: Session,
|
|
|
|
|
+):
|
|
|
|
|
+ payload = {
|
|
|
|
|
+ "name": "Lancelot",
|
|
|
|
|
+ "email": "lancelot@dulac.fr",
|
|
|
|
|
+ "phone_number": "03 14 15 92 65",
|
|
|
|
|
+ "comment": "it's a knight",
|
|
|
|
|
+ }
|
|
|
|
|
+ # Test normal payload
|
|
|
|
|
+ response = await client.post(
|
|
|
|
|
+ app.url_path_for("create_volunteer", project_id=default_project_id),
|
|
|
|
|
+ json=payload,
|
|
|
|
|
+ headers=default_user_headers,
|
|
|
|
|
+ )
|
|
|
|
|
+ assert response.status_code == 200
|
|
|
|
|
+ assert response.json()["id"] != default_project_id
|
|
|
|
|
+ assert response.json()["name"] == "Lancelot"
|
|
|
|
|
+ assert response.json()["comment"] != ""
|
|
|
|
|
+ new_id = response.json()["id"]
|
|
|
|
|
+ result = session.execute(select(Volunteer).where(Volunteer.id == new_id))
|
|
|
|
|
+ volunteer = result.scalar_one_or_none()
|
|
|
|
|
+ assert volunteer is not None
|
|
|
|
|
+ assert volunteer.comment == "it's a knight"
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
async def test_update_volunteer(
|
|
async def test_update_volunteer(
|
|
|
client: AsyncClient,
|
|
client: AsyncClient,
|
|
|
default_public_project: Project,
|
|
default_public_project: Project,
|
|
@@ -113,6 +143,7 @@ async def test_update_volunteer(
|
|
|
"email": "lancelot@dulac.fr",
|
|
"email": "lancelot@dulac.fr",
|
|
|
"phone_number": "03 14 15 92 65",
|
|
"phone_number": "03 14 15 92 65",
|
|
|
"automatic_sms": False,
|
|
"automatic_sms": False,
|
|
|
|
|
+ "comment": "new comment",
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
# test invalid project_id
|
|
# test invalid project_id
|
|
@@ -259,7 +290,8 @@ async def test_delete_volunteer(
|
|
|
|
|
|
|
|
# check deletion is cascaded to slots
|
|
# check deletion is cascaded to slots
|
|
|
result = session.execute(select(Slot).where(Slot.id == default_slot_id))
|
|
result = session.execute(select(Slot).where(Slot.id == default_slot_id))
|
|
|
- slot: Slot | None = result.scalars().first()
|
|
|
|
|
|
|
+ slot: Slot | None = result.scalar_one_or_none()
|
|
|
|
|
+ assert slot is not None
|
|
|
assert default_volunteer_id not in slot.volunteers_id
|
|
assert default_volunteer_id not in slot.volunteers_id
|
|
|
|
|
|
|
|
# Idempotence test
|
|
# Idempotence test
|