| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 import unittest | 3 import unittest |
| 4 import common | 4 import common |
| 5 | 5 |
| 6 from autotest_lib.client.common_lib import error, utils |
| 6 from autotest_lib.client.common_lib.test_utils import mock | 7 from autotest_lib.client.common_lib.test_utils import mock |
| 7 from autotest_lib.client.common_lib.hosts import base_classes | 8 from autotest_lib.client.common_lib.hosts import base_classes |
| 8 | 9 |
| 9 | 10 |
| 10 class test_host_class(unittest.TestCase): | 11 class test_host_class(unittest.TestCase): |
| 11 def setUp(self): | 12 def setUp(self): |
| 12 self.god = mock.mock_god() | 13 self.god = mock.mock_god() |
| 13 | 14 |
| 14 | 15 |
| 15 def tearDown(self): | 16 def tearDown(self): |
| 16 self.god.unstub_all() | 17 self.god.unstub_all() |
| 17 | 18 |
| 18 | 19 |
| 19 def test_run_output_notimplemented(self): | 20 def test_run_output_notimplemented(self): |
| 20 host = base_classes.Host() | 21 host = base_classes.Host() |
| 21 self.assertRaises(NotImplementedError, host.run_output, "fake command") | 22 self.assertRaises(NotImplementedError, host.run_output, "fake command") |
| 22 | 23 |
| 23 | 24 |
| 25 def test_check_diskspace(self): |
| 26 self.god.stub_function(base_classes.Host, 'run') |
| 27 host = base_classes.Host() |
| 28 host.hostname = 'unittest-host' |
| 29 test_df_tail = ('/dev/sda1 1061 939' |
| 30 ' 123 89% /') |
| 31 fake_cmd_status = utils.CmdResult(exit_status=0, stdout=test_df_tail) |
| 32 host.run.expect_call('df -PB 1000000 /foo | tail -1').and_return( |
| 33 fake_cmd_status) |
| 34 self.assertRaises(error.AutoservDiskFullHostError, |
| 35 host.check_diskspace, '/foo', 0.2) |
| 36 host.run.expect_call('df -PB 1000000 /foo | tail -1').and_return( |
| 37 fake_cmd_status) |
| 38 host.check_diskspace('/foo', 0.1) |
| 39 self.god.check_playback() |
| 40 |
| 41 |
| 24 if __name__ == "__main__": | 42 if __name__ == "__main__": |
| 25 unittest.main() | 43 unittest.main() |
| OLD | NEW |