test api: implement UsageStats arithmetic ops

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk 2020-08-10 06:30:14 -04:00
parent 91f0cbf6aa
commit 863947ddb8

View File

@ -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):