add: test for units

Signed-off-by: Kei Matsumoto <umaretekyoumade@gmail.com>
This commit is contained in:
Goryudyuma 2019-07-14 03:24:18 +09:00
parent 75d41edb94
commit 59491c7d77
No known key found for this signature in database
GPG Key ID: 4D4F3A52ACE7F202
1 changed files with 10 additions and 1 deletions

View File

@ -3,8 +3,8 @@ from __future__ import unicode_literals
import unittest
from compose.utils import unquote_path
from compose.cli.utils import human_readable_file_size
from compose.utils import unquote_path
class UnquotePathTest(unittest.TestCase):
@ -33,3 +33,12 @@ class HumanReadableFileSizeTest(unittest.TestCase):
def test_1023b(self):
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'