tests/testprettysize.py
author Radek Brich <radek.brich@devl.cz>
Thu, 10 May 2012 08:42:21 +0200
changeset 34 98c7809af415
parent 10 f3a1b9792cc9
permissions -rwxr-xr-x
Add PgDataCopy. Add TableCopyTool.Add SrcDstTablesTool class to toolbase, use in tablecopy, tablediff.

#!/usr/bin/env python3

import unittest
from pgtoolkit import prettysize

class TestHumansize(unittest.TestCase):
    def test_humansize(self):
        psize = prettysize.prettysize_short
        expected = (
            (0, '0'),
            (1000, '1000'),
            (1024, '1K'),
            (1050, '1.03K'),
            (2050, '2K'),
            (333333, '325.52K'),
            (1048576, '1M'),
            (1050000, '1M'),
            (5555555, '5.3M'),
            (1073741824, '1G'),
            )
        for input, result in expected:
            self.assertEqual(psize(input), result)


if __name__ == '__main__':
    unittest.main()