tests/test_prettysize.py
author Radek Brich <radek.brich@devl.cz>
Wed, 03 Apr 2013 15:57:36 +0200
changeset 81 f709b1c7ca0c
parent 50 f71d3abbb18f
permissions -rw-r--r--
PgManager: Update RowDict, add write support.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#!/usr/bin/env python3
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
50
f71d3abbb18f Add test_prettysize to tests.py.
Radek Brich <radek.brich@devl.cz>
parents: 10
diff changeset
     3
from pgtoolkit import prettysize
f71d3abbb18f Add test_prettysize to tests.py.
Radek Brich <radek.brich@devl.cz>
parents: 10
diff changeset
     4
2
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
import unittest
50
f71d3abbb18f Add test_prettysize to tests.py.
Radek Brich <radek.brich@devl.cz>
parents: 10
diff changeset
     6
2
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
50
f71d3abbb18f Add test_prettysize to tests.py.
Radek Brich <radek.brich@devl.cz>
parents: 10
diff changeset
     8
class TestPrettySize(unittest.TestCase):
f71d3abbb18f Add test_prettysize to tests.py.
Radek Brich <radek.brich@devl.cz>
parents: 10
diff changeset
     9
    def test_prettysize(self):
2
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
        psize = prettysize.prettysize_short
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
        expected = (
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
            (0, '0'),
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
            (1000, '1000'),
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
            (1024, '1K'),
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
            (1050, '1.03K'),
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
            (2050, '2K'),
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
            (333333, '325.52K'),
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
            (1048576, '1M'),
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
            (1050000, '1M'),
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
            (5555555, '5.3M'),
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
            (1073741824, '1G'),
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
            )
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
        for input, result in expected:
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
            self.assertEqual(psize(input), result)
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    25
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    26
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    27
if __name__ == '__main__':
efee419b7a2d Fix pgmanager exceptions.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    28
    unittest.main()
50
f71d3abbb18f Add test_prettysize to tests.py.
Radek Brich <radek.brich@devl.cz>
parents: 10
diff changeset
    29