From 0708a483016a7d81e625e98205b477fdf1fa97cc Mon Sep 17 00:00:00 2001 From: vikynoah Date: Thu, 13 Feb 2025 02:05:15 +0100 Subject: [PATCH] feat : Add Patch to obj lifecycle --- creyPY/fastapi/testing_unit.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/creyPY/fastapi/testing_unit.py b/creyPY/fastapi/testing_unit.py index c8607e0..42ddc94 100644 --- a/creyPY/fastapi/testing_unit.py +++ b/creyPY/fastapi/testing_unit.py @@ -140,6 +140,7 @@ class AbstractTestAPI(unittest.IsolatedAsyncioTestCase): pagination: bool = True, id_field: str = "id", created_at_check: bool = True, + patch: dict| None = None, ): # GET LIST re = await self.get(url) @@ -164,6 +165,14 @@ class AbstractTestAPI(unittest.IsolatedAsyncioTestCase): re = await self.get(f"{url}{obj_id}/") self.assertEqual(re[id_field], obj_id) + # PATCH + if patch: + for key, value in patch.items(): + input_obj[key] = value + re = await self.patch(f"{url}{obj_id}/", obj=input_obj) + for key, value in patch.items(): + self.assertEqual(re[key],value) + # GET LIST re = await self.get(url) if pagination: