refactor and unittest autotest_quickmerge
Refactoring and new tests. Changes:
1) Rename autotest-quickmerge -> autotest_quickmerge so that it can be
imported as python module.
2) Refactor argument parsing and rsync command running into their own
functions.
3) Add unittest for RsyncQuickmerge.
4) Add some docstrings.
BUG=chromium:229234
TEST=unit test passes
Change-Id: I0469cf87ca6b967e554ed38f2e183578034b7ff2
Reviewed-on: https://gerrit.chromium.org/gerrit/47591
Commit-Queue: Aviv Keshet <akeshet@chromium.org>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
Tested-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/scripts/autotest_quickmerge_unittest.py b/scripts/autotest_quickmerge_unittest.py
new file mode 100755
index 0000000..7f5b952
--- /dev/null
+++ b/scripts/autotest_quickmerge_unittest.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+
+# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Unit tests for autotest_quickmerge."""
+
+from chromite.lib import cros_build_lib_unittest
+from chromite.lib import cros_test_lib
+from chromite.scripts import autotest_quickmerge
+
+class RsyncCommandTest(cros_build_lib_unittest.RunCommandTestCase):
+
+ def testRsyncQuickmergeCommand(self):
+ """Test that RsyncQuickMerge makes correct call to SudoRunCommand"""
+ include_file_name = 'an_include_file_name'
+ source_path = 'a_source_path'
+ sysroot_path = 'a_sysroot_path'
+
+ expected_command = ['rsync', '-a', '-n', '-u', '-i',
+ '--exclude=**.pyc', '--exclude=**.pyo',
+ '--include-from=%s' % include_file_name,
+ '--exclude=*',
+ source_path,
+ sysroot_path]
+
+ autotest_quickmerge.RsyncQuickmerge(source_path, sysroot_path,
+ include_file_name,
+ pretend=True,
+ overwrite=False,
+ quiet=False)
+
+ self.assertCommandContains(expected_command)
+
+
+if __name__ == '__main__':
+ cros_test_lib.main()
\ No newline at end of file