1 #!/usr/bin/python 2 3 import unittest 4 import common 5 6 from autotest_lib.client.common_lib import error, utils 7 from autotest_lib.client.common_lib.test_utils import mock 8 from autotest_lib.client.common_lib.hosts import base_classes 9 10 11 class test_host_class(unittest.TestCase): 12 def setUp(self): 13 self.god = mock.mock_god() 14 15 16 def tearDown(self): 17 self.god.unstub_all() 18 19 20 def test_run_output_notimplemented(self): 21 host = base_classes.Host() 22 self.assertRaises(NotImplementedError, host.run_output, "fake command") 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 42 if __name__ == "__main__": 43 unittest.main() 44