]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests ensure human_readable_size works up to terabytes
authorAlfredo Deza <adeza@redhat.com>
Thu, 3 May 2018 16:52:21 +0000 (12:52 -0400)
committerAndrew Schoen <aschoen@redhat.com>
Wed, 13 Jun 2018 14:30:55 +0000 (09:30 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 4ad42f4244062995de003d8141cddcdc1d2b80fc)

src/ceph-volume/ceph_volume/tests/util/test_disk.py

index cbe111f04896f7d7b10771bff4bf0ee12f55eb3f..3339fe4483eb6ef0c962f1b1be8a807e8201422c 100644 (file)
@@ -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'