Add internal/lib/driver_test_lib.py to fix unit tests.
Add a script to run all unit tests.
Test: tools/acloud/run_tests.sh
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..415166b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*.pyc
+*.*~
diff --git a/README.md b/README.md
index ab5678f..045734a 100755
--- a/README.md
+++ b/README.md
@@ -11,4 +11,9 @@
`$ pip install acloud.zip`
#3. Execution:
+
`$ acloud <flags>
+
+To run all unit tests:
+
+ `$ tools\acloud\run_tests.sh`
diff --git a/internal/lib/driver_test_lib.py b/internal/lib/driver_test_lib.py
new file mode 100644
index 0000000..4ca1bfc
--- /dev/null
+++ b/internal/lib/driver_test_lib.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+#
+# Copyright 2017 - The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Driver test library."""
+
+import mock
+import unittest
+
+
+class BaseDriverTest(unittest.TestCase):
+ """Base class for driver tests."""
+
+ def setUp(self):
+ """Set up test."""
+ self._patchers = []
+
+ def tearDown(self):
+ """Tear down test."""
+ for patcher in reversed(self._patchers):
+ patcher.stop()
+
+ def Patch(self, *args, **kwargs):
+ """A wrapper for mock.patch.object.
+
+ This wrapper starts a patcher and store it in self._patchers,
+ so that we can later stop them in tearDown.
+
+ Args:
+ *args: Arguments to pass to mock.patch.
+ **kwargs: Keyword arguments to pass to mock.patch.
+
+ Returns:
+ Mock object
+ """
+ patcher = mock.patch.object(*args, **kwargs)
+ self._patchers.append(patcher)
+ return patcher.start()
diff --git a/public/device_driver_test.py b/public/device_driver_test.py
index eb0a64f..7b12f61 100644
--- a/public/device_driver_test.py
+++ b/public/device_driver_test.py
@@ -24,7 +24,7 @@
import unittest
from acloud.internal.lib import auth
-from acloud.internal.lib import andorid_build_client
+from acloud.internal.lib import android_build_client
from acloud.internal.lib import android_compute_client
from acloud.internal.lib import driver_test_lib
from acloud.internal.lib import gstorage_client
diff --git a/run_tests.sh b/run_tests.sh
new file mode 100755
index 0000000..d9d6987
--- /dev/null
+++ b/run_tests.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+if [ -z "$ANDROID_BUILD_TOP" ]; then
+ echo "Missing ANDROID_BUILD_TOP env variable. Run 'lunch' first."
+ exit 1
+fi
+
+# Runs all unit tests under tools/acloud.
+tests=$(find . -type f | grep test\.py)
+for t in $tests; do
+ PYTHONPATH=$ANDROID_BUILD_TOP/tools python $t;
+done