From 863947ddb8870cc5763af2cf96831bff990ea1fc Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Mon, 10 Aug 2020 06:30:14 -0400 Subject: [PATCH] test api: implement `UsageStats` arithmetic ops Signed-off-by: Michal Mielewczyk --- test/functional/api/cas/statistics.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/functional/api/cas/statistics.py b/test/functional/api/cas/statistics.py index 580264a..37f3d26 100644 --- a/test/functional/api/cas/statistics.py +++ b/test/functional/api/cas/statistics.py @@ -387,6 +387,9 @@ class UsageStats: f"Dirty: {self.dirty}\n" ) + def __repr__(self): + return str(self) + def __eq__(self, other): if not other: return False @@ -397,6 +400,24 @@ class UsageStats: and self.dirty == other.dirty ) + def __ne__(self, other): + return not self == other + + def __add__(self, other): + return UsageStats( + self.occupancy + other.occupancy, + self.free + other.free, + self.clean + other.clean, + self.dirty + other.dirty + ) + + def __iadd__(self, other): + self.occupancy += other.occupancy + self.free += other.free + self.clean += other.clean + self.dirty += other.dirty + return self + class InactiveUsageStats: def __init__(self, inactive_occupancy, inactive_clean, inactive_dirty):