From 644786d579fd425d4edde66714bf081586e4748b Mon Sep 17 00:00:00 2001 From: Marvin Vogt Date: Tue, 5 Dec 2023 14:46:07 +0000 Subject: [PATCH] Implement `__eq__` for `FRRoutingPrefix` & `CabourotteHealthcheck` --- src/anycastd/healthcheck/_cabourotte/main.py | 6 ++++++ src/anycastd/prefix/_frrouting/main.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/anycastd/healthcheck/_cabourotte/main.py b/src/anycastd/healthcheck/_cabourotte/main.py index 499bacf..9254178 100644 --- a/src/anycastd/healthcheck/_cabourotte/main.py +++ b/src/anycastd/healthcheck/_cabourotte/main.py @@ -25,6 +25,12 @@ def __repr__(self) -> str: f"interval={self.interval!r})" ) + def __eq__(self, other: object) -> bool: + if not isinstance(other, CabourotteHealthcheck): + return NotImplemented + + return self.__dict__ == other.__dict__ + @property def interval(self) -> datetime.timedelta: return self.__interval diff --git a/src/anycastd/prefix/_frrouting/main.py b/src/anycastd/prefix/_frrouting/main.py index d06a40b..6bf10cc 100644 --- a/src/anycastd/prefix/_frrouting/main.py +++ b/src/anycastd/prefix/_frrouting/main.py @@ -47,6 +47,12 @@ def __repr__(self) -> str: f"vtysh={self.vtysh!r}, executor={self.executor!r})" ) + def __eq__(self, other: object) -> bool: + if not isinstance(other, FRRoutingPrefix): + return NotImplemented + + return self.__dict__ == other.__dict__ + @property def prefix(self) -> IPv4Network | IPv6Network: return self.__prefix