Jelajahi Sumber

add: test for units

Signed-off-by: Kei Matsumoto <[email protected]>
Goryudyuma 6 tahun lalu
induk
melakukan
59491c7d77
1 mengubah file dengan 10 tambahan dan 1 penghapusan
  1. 10 1
      tests/unit/cli/utils_test.py

+ 10 - 1
tests/unit/cli/utils_test.py

@@ -3,8 +3,8 @@ from __future__ import unicode_literals
 
 
 import unittest
 import unittest
 
 
-from compose.utils import unquote_path
 from compose.cli.utils import human_readable_file_size
 from compose.cli.utils import human_readable_file_size
+from compose.utils import unquote_path
 
 
 
 
 class UnquotePathTest(unittest.TestCase):
 class UnquotePathTest(unittest.TestCase):
@@ -33,3 +33,12 @@ class HumanReadableFileSizeTest(unittest.TestCase):
 
 
     def test_1023b(self):
     def test_1023b(self):
         assert human_readable_file_size(1023) == '1023 B'
         assert human_readable_file_size(1023) == '1023 B'
+
+    def test_units(self):
+        assert human_readable_file_size((2 ** 10) ** 0) == '1 B'
+        assert human_readable_file_size((2 ** 10) ** 1) == '1 kB'
+        assert human_readable_file_size((2 ** 10) ** 2) == '1 MB'
+        assert human_readable_file_size((2 ** 10) ** 3) == '1 GB'
+        assert human_readable_file_size((2 ** 10) ** 4) == '1 TB'
+        assert human_readable_file_size((2 ** 10) ** 5) == '1 PB'
+        assert human_readable_file_size((2 ** 10) ** 6) == '1 EB'