def install(self, backend): """Install the GUI and dependencies.""" # If the source setting has changed since the last time this was run, # get the code, from either a static release or a branch as specified # by the souce setting, and install it. if backend.different("juju-gui-source"): # Get a tarball somehow. origin, version_or_branch = utils.parse_source(backend.config["juju-gui-source"]) if origin == "develop": # Develop is the latest passing build from Git. origin = "branch" version_or_branch = ("https://github.com/juju/juju-gui.git", "develop") if origin == "branch": logpath = backend.config["command-log-file"] # Make sure we have the required build dependencies. # Note that we also need to add the juju-gui repository # containing our version of nodejs. log("Installing build dependencies.") utils.install_missing_packages( utils.DEB_BUILD_DEPENDENCIES, repository=backend.config["repository-location"] ) branch_url, revision = version_or_branch log("Using source {}: {}".format(branch_url, revision)) release_tarball_path = utils.fetch_gui_from_branch(branch_url, revision, logpath) else: release_tarball_path = utils.fetch_gui_release(origin, version_or_branch) # Install the tarball. utils.setup_gui(release_tarball_path) else: log("No change to juju-gui-source. Skipping step.")
def test_trunk(self, mock_get_release_file_path): # The last development release is requested. for source in self.sources: with self.patch_launchpad('trunk', None, source): path = fetch_gui_release('trunk', None) self.assertEqual(source['release_path'], path) self.assertFalse(mock_get_release_file_path.called)
def test_version_found(self, mock_get_release_file_path): # A release version is specified and found locally. for source in self.sources: mock_get_release_file_path.return_value = source['release_path'] path = fetch_gui_release('stable', '0.1.42') self.assertEqual(source['release_path'], path) mock_get_release_file_path.assert_called_once_with('0.1.42') mock_get_release_file_path.reset_mock()
def test_local(self, mock_get_release_file_path): # The last local release is requested. for source in self.sources: mock_get_release_file_path.return_value = source['release_path'] path = fetch_gui_release('local', None) self.assertEqual(source['release_path'], path) mock_get_release_file_path.assert_called_once_with() mock_get_release_file_path.reset_mock()
def test_version_not_found(self, mock_get_release_file_path): # A release version is specified but not found locally. for source in self.sources: mock_get_release_file_path.return_value = None with self.patch_launchpad('stable', '0.1.42', source): path = fetch_gui_release('stable', '0.1.42') self.assertEqual(source['release_path'], path) mock_get_release_file_path.assert_called_once_with('0.1.42') mock_get_release_file_path.reset_mock()
def test_url(self, mock_download_release): # The release is retrieved from an URL. for source in self.sources: mock_download_release.return_value = source['release_path'] url = 'http://download.example.com/' + source['filename'] path = fetch_gui_release('url', url) self.assertEqual(source['release_path'], path) mock_download_release.assert_called_once_with( url, 'url-' + source['filename']) mock_download_release.reset_mock()
def install(self, backend): """Install the GUI and dependencies.""" # If the source setting has changed since the last time this was run, # get the code, from either a static release or a branch as specified # by the souce setting, and install it. if backend.different('juju-gui-source'): # Get a tarball somehow. origin, version_or_branch = utils.parse_source( backend.config['juju-gui-source']) if origin == 'develop': # Develop is the latest passing build from Git. origin = 'branch' version_or_branch = ('https://github.com/juju/juju-gui.git', 'develop') if origin == 'branch': logpath = backend.config['command-log-file'] # Make sure we have the required build dependencies. # Note that we also need to add the juju-gui repository # containing our version of nodejs. log('Installing build dependencies.') utils.install_missing_packages( utils.DEB_BUILD_DEPENDENCIES, repository=backend.config['repository-location']) branch_url, revision = version_or_branch log('Using source {}: {}'.format(branch_url, revision)) release_tarball_path = utils.fetch_gui_from_branch( branch_url, revision, logpath) else: release_tarball_path = utils.fetch_gui_release( origin, version_or_branch) # Install the tarball. utils.setup_gui(release_tarball_path) else: log('No change to juju-gui-source. Skipping step.')