From 23db68c96af3517c147f99b1db74cb9cd91c7977 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 3 May 2018 12:52:21 -0400 Subject: [PATCH] ceph-volume tests ensure human_readable_size works up to terabytes Signed-off-by: Alfredo Deza (cherry picked from commit 4ad42f4244062995de003d8141cddcdc1d2b80fc) --- .../ceph_volume/tests/util/test_disk.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/ceph-volume/ceph_volume/tests/util/test_disk.py b/src/ceph-volume/ceph_volume/tests/util/test_disk.py index cbe111f0489..3339fe4483e 100644 --- a/src/ceph-volume/ceph_volume/tests/util/test_disk.py +++ b/src/ceph-volume/ceph_volume/tests/util/test_disk.py @@ -123,3 +123,26 @@ class TestGetMapperDevs(object): assert result['dm-0'] == dm_path assert result[sda_path] == sda_path assert result[dm_path] == 'dm-0' + + +class TestHumanReadableSize(object): + + def test_bytes(self): + result = disk.human_readable_size(800) + assert result == '800.00 B' + + def test_kilobytes(self): + result = disk.human_readable_size(800*1024) + assert result == '800.00 KB' + + def test_megabytes(self): + result = disk.human_readable_size(800*1024*1024) + assert result == '800.00 MB' + + def test_gigabytes(self): + result = disk.human_readable_size(8.19*1024*1024*1024) + assert result == '8.19 GB' + + def test_terabytes(self): + result = disk.human_readable_size(81.2*1024*1024*1024*1024) + assert result == '81.20 TB' -- 2.47.3