]> git.proxmox.com Git - ceph.git/blame - ceph/src/test/pybind/test_ceph_daemon.py
import ceph quincy 17.2.1
[ceph.git] / ceph / src / test / pybind / test_ceph_daemon.py
CommitLineData
9f95a23c 1#!/usr/bin/env python3
7c673cae
FG
2# -*- mode:python; tab-width:4; indent-tabs-mode:t -*-
3# vim: ts=4 sw=4 smarttab expandtab
4#
5"""
6Copyright (C) 2015 Red Hat
7
8This is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public
10License version 2, as published by the Free Software
11Foundation. See file COPYING.
12"""
13
33c7a0ef 14import unittest
7c673cae
FG
15
16from ceph_daemon import DaemonWatcher
17
18try:
19 from StringIO import StringIO
20except ImportError:
21 from io import StringIO
22
23
33c7a0ef 24class TestDaemonWatcher(unittest.TestCase):
7c673cae
FG
25 def test_format(self):
26 dw = DaemonWatcher(None)
27
28 self.assertEqual(dw.format_dimless(1, 4), " 1 ")
29 self.assertEqual(dw.format_dimless(1000, 4), "1.0k")
30 self.assertEqual(dw.format_dimless(3.14159, 4), " 3 ")
31 self.assertEqual(dw.format_dimless(1400000, 4), "1.4M")
32
33 def test_col_width(self):
34 dw = DaemonWatcher(None)
35
36 self.assertEqual(dw.col_width("foo"), 4)
37 self.assertEqual(dw.col_width("foobar"), 6)
38
39 def test_supports_color(self):
40 dw = DaemonWatcher(None)
41 # Can't count on having a tty available during tests, so only test the false case
33c7a0ef
TL
42 self.assertFalse(dw.supports_color(StringIO()))
43
44
45if __name__ == '__main__':
46 unittest.main()
47
9f95a23c 48
7c673cae 49# Local Variables:
9f95a23c 50# compile-command: "cd ../../..;
33c7a0ef 51# PYTHONPATH=src/pybind python3 src/test/pybind/test_ceph_daemon.py"
7c673cae 52# End: