Skip to content

Commit

Permalink
Remove not needed methods
Browse files Browse the repository at this point in the history
  • Loading branch information
eos87 committed Dec 12, 2024
1 parent 1c8d270 commit e3e6514
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 33 deletions.
12 changes: 0 additions & 12 deletions server/planning/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
21 changes: 0 additions & 21 deletions server/planning/types/event.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit e3e6514

Please sign in to comment.