diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/test/pybind/test_ceph_daemon.py | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/pybind/test_ceph_daemon.py')
-rwxr-xr-x | src/test/pybind/test_ceph_daemon.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/test/pybind/test_ceph_daemon.py b/src/test/pybind/test_ceph_daemon.py new file mode 100755 index 000000000..df8d4c0b0 --- /dev/null +++ b/src/test/pybind/test_ceph_daemon.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +# -*- mode:python; tab-width:4; indent-tabs-mode:t -*- +# vim: ts=4 sw=4 smarttab expandtab +# +""" +Copyright (C) 2015 Red Hat + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public +License version 2, as published by the Free Software +Foundation. See file COPYING. +""" + +import unittest + +from ceph_daemon import DaemonWatcher + +try: + from StringIO import StringIO +except ImportError: + from io import StringIO + + +class TestDaemonWatcher(unittest.TestCase): + def test_format(self): + dw = DaemonWatcher(None) + + self.assertEqual(dw.format_dimless(1, 4), " 1 ") + self.assertEqual(dw.format_dimless(1000, 4), "1.0k") + self.assertEqual(dw.format_dimless(3.14159, 4), " 3 ") + self.assertEqual(dw.format_dimless(1400000, 4), "1.4M") + + def test_col_width(self): + dw = DaemonWatcher(None) + + self.assertEqual(dw.col_width("foo"), 4) + self.assertEqual(dw.col_width("foobar"), 6) + + def test_supports_color(self): + dw = DaemonWatcher(None) + # Can't count on having a tty available during tests, so only test the false case + self.assertFalse(dw.supports_color(StringIO())) + + +if __name__ == '__main__': + unittest.main() + + +# Local Variables: +# compile-command: "cd ../../..; +# PYTHONPATH=src/pybind python3 src/test/pybind/test_ceph_daemon.py" +# End: |