remote_access: Simplify RemoteAccess connection.
Previously when using the RemoteAccess object it was possible to misuse
the object by trying to execute a remote function before Connect() was
called.
This CL changes the connection logic so that the connection is made
automatically as soon as the agent is needed. Also cleans up the setup
and device work dir logic so users can do everything from the
constructor.
BUG=brillo:948
TEST=cbuildbot/run_tests
TEST=brillo shell --device <ip>
TEST=cros deploy <ip> <package>
Change-Id: Id7abb1824395a116a6951ac440fab7b5d02d0587
Reviewed-on: https://chromium-review.googlesource.com/268664
Trybot-Ready: David Pursell <dpursell@chromium.org>
Tested-by: David Pursell <dpursell@chromium.org>
Reviewed-by: Yiming Chen <yimingc@chromium.org>
Commit-Queue: David Pursell <dpursell@chromium.org>
diff --git a/cli/deploy_unittest.py b/cli/deploy_unittest.py
index 8d2c0af..fbc08f2 100644
--- a/cli/deploy_unittest.py
+++ b/cli/deploy_unittest.py
@@ -35,7 +35,10 @@
return cros_build_lib.CommandResult(output=self.remote_sh_output)
def __init__(self):
- self.agent = self.RemoteAccessFake()
+ self._agent = self.RemoteAccessFake()
+
+ def GetAgent(self):
+ return self._agent
class DbApiFake(object):
@@ -80,7 +83,7 @@
self.scanner = deploy._InstallPackageScanner(self._BUILD_ROOT)
def SetupVartree(self, vartree_pkgs):
- self.device.agent.remote_sh_output = json.dumps(vartree_pkgs)
+ self.device.GetAgent().remote_sh_output = json.dumps(vartree_pkgs)
def SetupBintree(self, bintree_pkgs):
bintree = PortageTreeFake(DbApiFake(bintree_pkgs))