Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(649)

Side by Side Diff: client/common_lib/hosts/base_classes_unittest.py

Issue 6551020: Merge remote branch 'autotest-upstream/master' into try-box1 (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/common_lib/hosts/base_classes.py ('k') | client/common_lib/hosts/common.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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()
OLDNEW
« no previous file with comments | « client/common_lib/hosts/base_classes.py ('k') | client/common_lib/hosts/common.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698