From edcb055f50409e403128717096b32641cdcf07c8 Mon Sep 17 00:00:00 2001 From: Alejandra <90076947+alejsdev@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:57:18 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20bug=20in=20update=5Forgani?= =?UTF-8?q?zation=20and=20refactor=20test=20(#29)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/routes/organizations.py | 2 ++ backend/app/tests/api/routes/test_organizations.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/app/api/routes/organizations.py b/backend/app/api/routes/organizations.py index 18a0b52833..32dda927ae 100644 --- a/backend/app/api/routes/organizations.py +++ b/backend/app/api/routes/organizations.py @@ -130,6 +130,8 @@ def update_organization( update_dict = organization_in.model_dump(exclude_unset=True) org = link.organization org.sqlmodel_update(update_dict) + session.add(org) + session.commit() return org diff --git a/backend/app/tests/api/routes/test_organizations.py b/backend/app/tests/api/routes/test_organizations.py index 5b387fc203..c29f51ad81 100644 --- a/backend/app/tests/api/routes/test_organizations.py +++ b/backend/app/tests/api/routes/test_organizations.py @@ -154,9 +154,10 @@ def test_update_organization(client: TestClient, db: Session) -> None: assert response.status_code == 200 data = response.json() + db.refresh(organization) assert data["id"] == organization.id - assert data["name"] == organization_in["name"] - assert data["description"] == organization_in["description"] + assert organization.name == organization_in["name"] + assert organization.description == organization_in["description"] def test_update_organization_not_found(client: TestClient) -> None: