From e3e65147805a3949950d268c3b5c660ce3115942 Mon Sep 17 00:00:00 2001 From: Helmy Giacoman Date: Thu, 12 Dec 2024 13:33:29 +0100 Subject: [PATCH] Remove not needed methods --- server/planning/tests/__init__.py | 12 ------------ server/planning/types/event.py | 21 --------------------- 2 files changed, 33 deletions(-) diff --git a/server/planning/tests/__init__.py b/server/planning/tests/__init__.py index e2261fb76..f9d056f4d 100644 --- a/server/planning/tests/__init__.py +++ b/server/planning/tests/__init__.py @@ -17,15 +17,3 @@ def setup_test_user(self): user = {"_id": ObjectId()} self.app.data.insert("users", [user]) g.user = user - - async def setUp(self): - """ - Set up the test case by entering the application's asynchronous context. - This ensures all tests run within the same app context, avoiding repetitive - boilerplate and allowing automatic resource cleanup, even if a test fails. - - Using `enterAsyncContext` ensures the app context (`self.app.app_context()`) - is properly exited after each test. - """ - - self.ctx = await self.enterAsyncContext(self.app.app_context()) diff --git a/server/planning/types/event.py b/server/planning/types/event.py index 11ee04c95..ded74ed7c 100644 --- a/server/planning/types/event.py +++ b/server/planning/types/event.py @@ -1,5 +1,3 @@ -from copy import deepcopy -from typing_extensions import Self from pydantic import Field from datetime import datetime from typing import Annotated, Any @@ -9,7 +7,6 @@ from superdesk.utc import utcnow from superdesk.core.resources import fields, dataclass, Dataclass from superdesk.core.resources.validators import validate_data_relation_async -from superdesk.utils import merge_dicts_deep from .base import BasePlanningModel from .event_dates import EventDates, OccurStatus @@ -275,21 +272,3 @@ class EventResourceModel(BasePlanningModel, LockFieldsMixin): related_items: list[RelatedItem] = Field(default_factory=list) failed_planned_ids: list[str] = Field(default_factory=list) - - def clone_with(self, updates: dict[str, Any]) -> Self: - """ - Deeply clones the instance and applies updates with proper validation. - - Addresses limitations of Pydantic's `model_copy`, which doesn't handle - nested data classes or validate updates the given updates. - - Args: - updates (dict[str, Any]): Attributes to update in the cloned instance. - - Returns: - Self: A new instance with the applied updates. - """ - - cloned_data = deepcopy(self.to_dict()) - cloned_data = dict(merge_dicts_deep(cloned_data, updates)) - return self.from_dict(cloned_data)