tests/test_prettysize.py
author Radek Brich <radek.brich@devl.cz>
Tue, 11 Dec 2012 10:49:42 +0100
changeset 52 26121a8fe78b
parent 50 f71d3abbb18f
permissions -rw-r--r--
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.

#!/usr/bin/env python3

from pgtoolkit import prettysize

import unittest


class TestPrettySize(unittest.TestCase):
    def test_prettysize(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()