From ab06bd5f44b0d567b63024ad7c3df14d5c962528 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 28 Sep 2022 11:10:34 +0200 Subject: [PATCH] fix remain_lifetime_percentage --- ereuse_devicehub/resources/action/schemas.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ereuse_devicehub/resources/action/schemas.py b/ereuse_devicehub/resources/action/schemas.py index 56165555..45e267b2 100644 --- a/ereuse_devicehub/resources/action/schemas.py +++ b/ereuse_devicehub/resources/action/schemas.py @@ -296,6 +296,14 @@ class TestDataStorage(Test): offline_uncorrectable = Integer(data_key='offlineUncorrectable') remaining_lifetime_percentage = Integer(data_key='remainingLifetimePercentage') + @post_load + def default_remaining_lifetime_percentage(self, data): + if not data.get('remaining_lifetime_percentage'): + return + + if data.get('remaining_lifetime_percentage') > 100: + data['remaining_lifetime_percentage'] = 100 + class StressTest(Test): __doc__ = m.StressTest.__doc__