From ab06bd5f44b0d567b63024ad7c3df14d5c962528 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 28 Sep 2022 11:10:34 +0200 Subject: [PATCH 1/2] 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__ From 60992a13da480dbd72ad6b3922e9ed1db2c93769 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 28 Sep 2022 11:55:31 +0200 Subject: [PATCH 2/2] change 100 for None --- ereuse_devicehub/resources/action/schemas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ereuse_devicehub/resources/action/schemas.py b/ereuse_devicehub/resources/action/schemas.py index 45e267b2..f24e2c83 100644 --- a/ereuse_devicehub/resources/action/schemas.py +++ b/ereuse_devicehub/resources/action/schemas.py @@ -302,7 +302,7 @@ class TestDataStorage(Test): return if data.get('remaining_lifetime_percentage') > 100: - data['remaining_lifetime_percentage'] = 100 + data['remaining_lifetime_percentage'] = None class StressTest(Test):