Install cuttlefish-common from github.
- Fix users can't install cuttlefish-common from 'apt-get'.
Bug: 145094322
Test: acloud-dev setup --host --force
Change-Id: I4be6248cc4c6ad690c244c2b9e858cc17f30a17b
diff --git a/setup/host_setup_runner_test.py b/setup/host_setup_runner_test.py
index b424db5..111540e 100644
--- a/setup/host_setup_runner_test.py
+++ b/setup/host_setup_runner_test.py
@@ -13,13 +13,17 @@
# limitations under the License.
"""Tests for host_setup_runner."""
import platform
+import shutil
+import tempfile
import unittest
+import mock
from acloud.internal.lib import driver_test_lib
from acloud.internal.lib import utils
from acloud.setup import setup_common
-from acloud.setup.host_setup_runner import CuttlefishHostSetup
from acloud.setup.host_setup_runner import AvdPkgInstaller
+from acloud.setup.host_setup_runner import CuttlefishCommonPkgInstaller
+from acloud.setup.host_setup_runner import CuttlefishHostSetup
class CuttlefishHostSetupTest(driver_test_lib.BaseDriverTest):
@@ -85,9 +89,36 @@
def testShouldNotRun(self):
"""Test ShoudRun should raise error in non-linux os."""
self.Patch(platform, "system", return_value="Mac")
-
self.assertFalse(self.AvdPkgInstaller.ShouldRun())
+class CuttlefishCommonPkgInstallerTest(driver_test_lib.BaseDriverTest):
+ """Test CuttlefishCommonPkgInstallerTest."""
+
+ # pylint: disable=invalid-name
+ def setUp(self):
+ """Set up the test."""
+ super(CuttlefishCommonPkgInstallerTest, self).setUp()
+ self.CuttlefishCommonPkgInstaller = CuttlefishCommonPkgInstaller()
+
+ def testShouldRun(self):
+ """Test ShoudRun."""
+ self.Patch(platform, "system", return_value="Linux")
+ self.Patch(setup_common, "PackageInstalled", return_value=False)
+ self.assertTrue(self.CuttlefishCommonPkgInstaller.ShouldRun())
+
+ @mock.patch.object(shutil, "rmtree")
+ @mock.patch.object(setup_common, "CheckCmdOutput")
+ def testRun(self, mock_cmd, mock_rmtree):
+ """Test Run."""
+ fake_tmp_folder = "/tmp/cf-common"
+ self.Patch(tempfile, "mkdtemp", return_value=fake_tmp_folder)
+ self.Patch(utils, "GetUserAnswerYes", return_value="y")
+ self.Patch(CuttlefishCommonPkgInstaller, "ShouldRun", return_value=True)
+ self.CuttlefishCommonPkgInstaller.Run()
+ self.assertEqual(mock_cmd.call_count, 1)
+ mock_rmtree.assert_called_once_with(fake_tmp_folder)
+
+
if __name__ == "__main__":
unittest.main()