Skip to content

Commit 3bceac6

Browse files
committed
fix: remove tests for start to use client helpers from microgrid client.
1 parent f3471fe commit 3bceac6

File tree

8 files changed

+17
-821
lines changed

8 files changed

+17
-821
lines changed

src/frequenz/client/assets/electrical_component/_electrical_component.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import dataclasses
44
from dataclasses import dataclass
5+
from typing import Any, Self
56

67
from frequenz.client.common.microgrid import MicrogridId
78
from frequenz.client.common.microgrid.electrical_components import ElectricalComponentId
@@ -42,6 +43,22 @@ class ElectricalComponent:
4243
operational_lifetime: Lifetime = dataclasses.field(default_factory=Lifetime)
4344
"""The operational lifetime of the electrical component."""
4445

46+
def __new__(cls, *_: Any, **__: Any) -> Self:
47+
"""Prevent instantiation of this class."""
48+
if cls is ElectricalComponent:
49+
raise TypeError(f"Cannot instantiate {cls.__name__} directly")
50+
return super().__new__(cls)
51+
52+
@property
53+
def identity(self) -> tuple[ElectricalComponentId, MicrogridId]:
54+
"""The identity of this component.
55+
56+
This uses the electrical component ID and microgrid ID to identify a component
57+
without considering the other attributes, so even if a component state
58+
changed, the identity remains the same.
59+
"""
60+
return (self.id, self.microgrid_id)
61+
4562
def __str__(self) -> str:
4663
"""Return the ID of this electrical component as a string."""
4764
name = f":{self.name}" if self.name else ""

tests/conftest.py

Lines changed: 0 additions & 72 deletions
This file was deleted.

tests/helpers/__init__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/helpers/assertions.py

Lines changed: 0 additions & 117 deletions
This file was deleted.

tests/helpers/factories.py

Lines changed: 0 additions & 150 deletions
This file was deleted.

0 commit comments

Comments
 (0)