From: Alfredo Deza Date: Thu, 3 May 2018 16:52:21 +0000 (-0400) Subject: ceph-volume tests ensure human_readable_size works up to terabytes X-Git-Tag: v12.2.8~70^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=23db68c96af3517c147f99b1db74cb9cd91c7977;p=ceph.git ceph-volume tests ensure human_readable_size works up to terabytes Signed-off-by: Alfredo Deza (cherry picked from commit 4ad42f4244062995de003d8141cddcdc1d2b80fc) --- 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 cbe111f04896..3339fe4483eb 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'