diff --git a/napalm_servertech_pro2/utils.py b/napalm_servertech_pro2/utils.py index 2b1527d..957804f 100644 --- a/napalm_servertech_pro2/utils.py +++ b/napalm_servertech_pro2/utils.py @@ -13,7 +13,7 @@ def convert_uptime(uptime): ) if not m: raise ValueError("uptime string was not recognized: regex did not match") - return ( + return float( int(m.group("days")) * 86400 + int(m.group("hours")) * 3600 + int(m.group("minutes")) * 60 diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py index f396a19..5a97a2b 100644 --- a/tests/utils/test_utils.py +++ b/tests/utils/test_utils.py @@ -6,13 +6,13 @@ def test_convert_uptime(): uptime = "11 days 4 hours 8 minutes 6 seconds" - assert utils.convert_uptime(uptime) == 965286 + assert utils.convert_uptime(uptime) == 965286.0 uptime = "133 days 1 hour 12 minutes 15 seconds" - assert isinstance(utils.convert_uptime(uptime), int) + assert isinstance(utils.convert_uptime(uptime), float) uptime = "0 days 0 hours 0 minutes 1 second" - assert utils.convert_uptime(uptime) == 1 + assert utils.convert_uptime(uptime) == 1.0 with pytest.raises(ValueError): utils.convert_uptime("hello")