From 8e265da3896440aa815eafe00fd642da8993959e Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Tue, 12 Feb 2019 07:22:58 +0000 Subject: [PATCH] mgr/orchestrator: fix device pretty-print, added unit test Signed-off-by: Ricardo Dias --- src/pybind/mgr/orchestrator.py | 5 +++-- src/pybind/mgr/orchestrator_cli/test_orchestrator.py | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index 0f5c12ee1f0..408c8ee5145 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -788,8 +788,9 @@ class InventoryDevice(object): return row_format.format("Device Path", "Type", "Size", "Rotates", "Available", "Model") else: - return row_format.format(self.id, self.type if self.type is not None else "", - format_bytes(self.size, 5, colored=False), + return row_format.format(str(self.id), self.type if self.type is not None else "", + format_bytes(self.size if self.size is not None else 0, 5, + colored=False), str(self.rotates), str(self.available), self.dev_id if self.dev_id is not None else "") diff --git a/src/pybind/mgr/orchestrator_cli/test_orchestrator.py b/src/pybind/mgr/orchestrator_cli/test_orchestrator.py index b0c8742b551..4152cc8cfa4 100644 --- a/src/pybind/mgr/orchestrator_cli/test_orchestrator.py +++ b/src/pybind/mgr/orchestrator_cli/test_orchestrator.py @@ -2,7 +2,7 @@ from __future__ import absolute_import import pytest -from orchestrator import DriveGroupSpec, DeviceSelection, DriveGroupValidationError +from orchestrator import DriveGroupSpec, DeviceSelection, DriveGroupValidationError, InventoryDevice def test_DriveGroup(): @@ -34,3 +34,7 @@ def test_drive_selection(): with pytest.raises(DriveGroupValidationError, match='exclusive'): DeviceSelection(paths=['/dev/sda'], rotates=False) +def test_inventory_device(): + i_d = InventoryDevice() + s = i_d.pretty_print() + assert len(s) -- 2.47.3