コード例 #1
0
    def test_second_unit_raises_error(self):
        """Create a duplicate content unit with different ``artifacts`` and same ``relative_path``.

        Artifacts are unique by ``relative_path`` and ``file``.
        """
        delete_orphans()
        content_api = ContentFilesApi(self.client)
        repo_api = RepositoriesFileApi(self.client)

        repo = repo_api.create(gen_repo())
        self.addCleanup(repo_api.delete, repo.pulp_href)

        artifact = gen_artifact()

        # create first content unit.
        content_attrs = gen_file_content_attrs(artifact)
        response = content_api.create(**content_attrs)
        monitor_task(response.task)

        artifact = gen_artifact(file=__file__)

        # create second content unit.
        second_content_attrs = gen_file_content_attrs(artifact)
        second_content_attrs["relative_path"] = content_attrs["relative_path"]
        response = content_api.create(**second_content_attrs)
        monitor_task(response.task)

        data = {
            "add_content_units":
            [c.pulp_href for c in content_api.list().results]
        }
        response = repo_api.modify(repo.pulp_href, data)
        with self.assertRaises(PulpTaskError) as cm:
            monitor_task(response.task)
        task = cm.exception.task.to_dict()

        error_message = ("Cannot create repository version. "
                         "More than one file.file content with "
                         "the duplicate values for relative_path.")
        self.assertEqual(task["error"]["description"], error_message)
コード例 #2
0
    def test_second_unit_replaces_the_first(self):
        """Create a duplicate content unit with different ``artifacts`` and same ``relative_path``.

        Artifacts are unique by ``relative_path`` and ``file``.
        """
        delete_orphans()
        content_api = ContentFilesApi(self.client)
        repo_api = RepositoriesFileApi(self.client)
        versions_api = RepositoriesFileVersionsApi(self.client)

        repo = repo_api.create(gen_repo())
        self.addCleanup(repo_api.delete, repo.pulp_href)

        artifact = gen_artifact()

        # create first content unit.
        content_attrs = gen_file_content_attrs(artifact)
        content_attrs["repository"] = repo.pulp_href
        response = content_api.create(**content_attrs)
        monitor_task(response.task)

        artifact = gen_artifact(file=__file__)

        # create second content unit.
        second_content_attrs = gen_file_content_attrs(artifact)
        second_content_attrs["repository"] = repo.pulp_href
        second_content_attrs["relative_path"] = content_attrs["relative_path"]

        response = content_api.create(**second_content_attrs)
        monitor_task(response.task)

        repo_latest_version = versions_api.read(
            repo_api.read(repo.pulp_href).latest_version_href)

        self.assertEqual(
            repo_latest_version.content_summary.present["file.file"]["count"],
            1)
コード例 #3
0
ファイル: test_bindings.py プロジェクト: ekohl/pulpcore
pprint(sync_response)

# Monitor the sync task
created_resources = monitor_task(sync_response.task)

repository_version_1 = repoversions.read(created_resources[0])
pprint(repository_version_1)

# Create an artifact from a local file
file_path = os.path.join(os.environ['TRAVIS_BUILD_DIR'], '.travis/test_bindings.py')
artifact = artifacts.create(file=file_path)
pprint(artifact)

# Create a FileContent from the artifact
filecontent_response = filecontent.create(relative_path='foo.tar.gz', artifact=artifact.pulp_href)
created_resources = monitor_task(filecontent_response.task)

# Add the new FileContent to a repository version
repo_version_data = {'add_content_units': [created_resources[0]]}
repo_version_response = repoversions.create(repository.pulp_href, repo_version_data)

# Monitor the repo version creation task
created_resources = monitor_task(repo_version_response.task)

repository_version_2 = repoversions.read(created_resources[0])
pprint(repository_version_2)

# Create a publication from the latest version of the repository
publish_data = FilePublication(repository=repository.pulp_href)
publish_response = filepublications.create(publish_data)