]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/pybind/test_ceph_daemon.py
2 # -*- mode:python; tab-width:4; indent-tabs-mode:t -*-
3 # vim: ts=4 sw=4 smarttab expandtab
6 Copyright (C) 2015 Red Hat
8 This is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public
10 License version 2, as published by the Free Software
11 Foundation. See file COPYING.
14 from unittest
import TestCase
16 from ceph_daemon
import DaemonWatcher
19 from StringIO
import StringIO
21 from io
import StringIO
24 class TestDaemonWatcher(TestCase
):
25 def test_format(self
):
26 dw
= DaemonWatcher(None)
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")
33 def test_col_width(self
):
34 dw
= DaemonWatcher(None)
36 self
.assertEqual(dw
.col_width("foo"), 4)
37 self
.assertEqual(dw
.col_width("foobar"), 6)
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
42 self
.assertEqual(dw
.supports_color(StringIO()), False)
45 # compile-command: "cd ../../..;
46 # PYTHONPATH=src/pybind nosetests --stop \
47 # src/test/pybind/test_ceph_daemon.py"