def publish_repo(self, repo, publish_conduit, config): """ Publish the ISO repository. :param repo: metadata describing the repo :type repo: pulp.plugins.model.Repository :param publish_conduit: The conduit for publishing a repo :type publish_conduit: pulp.plugins.conduits.repo_publish.RepoPublishConduit :param config: plugin configuration :type config: pulp.plugins.config.PluginConfiguration :return: report describing the publish operation :rtype: pulp.plugins.model.PublishReport """ return publish.publish(repo, publish_conduit, config)
def test_publish(self): """ Test the publish method. """ repo = MagicMock(spec=Repository) repo.id = "lebowski" repo.working_dir = self.temp_dir publish_conduit = distributor_mocks.get_publish_conduit(existing_units=self.existing_units) config = distributor_mocks.get_basic_config( **{constants.CONFIG_SERVE_HTTP: True, constants.CONFIG_SERVE_HTTPS: True} ) # We haven't implemented reporting yet, so we don't yet assert anything about the report # here. report = publish.publish(repo, publish_conduit, config) # Let's verify that the publish directory looks right publishing_paths = [ os.path.join(directory, "lebowski") for directory in [constants.ISO_HTTP_DIR, constants.ISO_HTTPS_DIR] ] for publishing_path in publishing_paths: for unit in self.existing_units: expected_symlink_path = os.path.join(publishing_path, unit.unit_key["name"]) self.assertTrue(os.path.islink(expected_symlink_path)) expected_symlink_destination = os.path.join("/", "path", unit.unit_key["name"]) self.assertEqual(os.path.realpath(expected_symlink_path), expected_symlink_destination) # Now let's have a look at the PULP_MANIFEST file to make sure it was generated and # published correctly. manifest_filename = os.path.join(publishing_path, constants.ISO_MANIFEST_FILENAME) manifest_rows = [] with open(manifest_filename) as manifest_file: manifest = csv.reader(manifest_file) for row in manifest: manifest_rows.append(row) expected_manifest_rows = [["test.iso", "sum1", "1"], ["test2.iso", "sum2", "2"], ["test3.iso", "sum3", "3"]] self.assertEqual(manifest_rows, expected_manifest_rows)