]>
Commit | Line | Data |
---|---|---|
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 | """ | |
6 | Copyright (C) 2015 Red Hat | |
7 | ||
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. | |
12 | """ | |
13 | ||
14 | from unittest import TestCase | |
15 | ||
16 | from ceph_daemon import DaemonWatcher | |
17 | ||
18 | try: | |
19 | from StringIO import StringIO | |
20 | except ImportError: | |
21 | from io import StringIO | |
22 | ||
23 | ||
24 | class TestDaemonWatcher(TestCase): | |
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 | |
42 | self.assertEqual(dw.supports_color(StringIO()), False) | |
9f95a23c | 43 | |
7c673cae | 44 | # Local Variables: |
9f95a23c TL |
45 | # compile-command: "cd ../../..; |
46 | # PYTHONPATH=src/pybind nosetests --stop \ | |
47 | # src/test/pybind/test_ceph_daemon.py" | |
7c673cae | 48 | # End: |