Ryan Cui | 47f80e4 | 2013-04-01 19:01:54 -0700 | [diff] [blame^] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | import os |
| 8 | import sys |
| 9 | |
| 10 | sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__))) |
| 11 | from chromite.lib import cros_test_lib |
| 12 | from chromite.lib import stats |
| 13 | from chromite.lib import stats_unittest |
| 14 | from chromite.scripts import cros |
| 15 | |
| 16 | |
| 17 | # pylint: disable=W0212 |
| 18 | |
| 19 | |
| 20 | class RunScriptTest(cros_test_lib.MockTempDirTestCase): |
| 21 | """Test the main functionality.""" |
| 22 | |
| 23 | def setUp(self): |
| 24 | self.StartPatcher(stats_unittest.StatsModuleMock()) |
| 25 | self.PatchObject(cros, '_RunSubCommand', autospec=True) |
| 26 | |
| 27 | def testStatsUpload(self): |
| 28 | """Test stats uploading.""" |
| 29 | return_value = cros.main(['chrome-sdk', '--board', 'lumpy']) |
| 30 | self.assertEquals(stats.StatsUploader._Upload.call_count, 1) |
| 31 | self.assertEquals(return_value, 0) |
| 32 | |
| 33 | |
| 34 | if __name__ == '__main__': |
| 35 | cros_test_lib.main() |