def _initialize(self, target_file_owner=None, *args, **dargs): super(Host, self)._initialize(*args, **dargs) self.serverdir = utils.get_server_dir() self.monitordir = os.path.join(os.path.dirname(__file__), "monitors") self.bootloader = bootloader.Bootloader(self) self.env = {} self.target_file_owner = target_file_owner
def test_get_path_automatically_installs(self): BOOTTOOL_DST = "/unittest/tmp/boottool" host = self.create_mock_host() loader = bootloader.Bootloader(host) # mock out loader.install_boottool mock_install = \ self.create_install_boottool_mock(loader, BOOTTOOL_DST) # set up the recording mock_install.expect_call() # run the test self.assertEquals(loader._get_boottool_path(), BOOTTOOL_DST) self.god.check_playback()
def test_installs_to_tmpdir(self): TMPDIR = "/unittest/tmp" SERVERDIR = "/unittest/server" BOOTTOOL_SRC = os.path.join(SERVERDIR, bootloader.BOOTTOOL_CLI_PATH) BOOTTOOL_SRC = os.path.abspath(BOOTTOOL_SRC) BOOTTOOL_DST = os.path.join(TMPDIR, "boottool.py") # set up the recording host = self.create_mock_host() host.get_tmp_dir.expect_call().and_return(TMPDIR) utils.get_server_dir.expect_call().and_return(SERVERDIR) host.send_file.expect_call(BOOTTOOL_SRC, TMPDIR) # run the test loader = bootloader.Bootloader(host) loader._install_boottool() # assert the playback is correct self.god.check_playback() # assert the final dest is correct self.assertEquals(loader._boottool_path, BOOTTOOL_DST)
def test_install_fails_without_host(self): host = self.create_mock_host() loader = bootloader.Bootloader(host) del host self.assertRaises(error.AutoservError, loader._install_boottool)