Пример #1
0
    def test_raise_error(self):
        """Create a duplicate content unit using same relative_path.

        Artifacts are unique by ``relative_path`` and ``file``.

        In order to raise an HTTP error, the same ``artifact`` and the same
        ``relative_path`` should be used.
        """
        delete_orphans()
        artifact = gen_artifact(self.CONTENT_URL)
        attrs = self.gen_content_attrs(artifact)

        # create first content unit.
        response = self.content_api.create(**attrs)
        created_resources = monitor_task(response.task)
        self.content_api.read(created_resources[0])

        # using the same attrs used to create the first content unit.
        response = self.content_api.create(**attrs)
        with self.assertRaises(PulpTaskError) as exc:
            monitor_task(response.task)
        self.assertEqual(exc.exception.task.state, "failed")
        error = exc.exception.task.error
        for key in ("already", "relative", "path", "sha256"):
            self.assertIn(key, error["description"].lower(), error)
Пример #2
0
    def test_non_error(self):
        """Create a duplicate content unit with different relative_path.

        Artifacts are unique by ``relative_path`` and ``file``.

        In order to avoid an HTTP error, use the same ``artifact`` and
        different ``relative_path``.
        """
        delete_orphans()
        artifact = gen_artifact(self.CONTENT_URL)
        attrs = self.gen_content_attrs(artifact)

        # create first content unit.
        response = self.content_api.create(**attrs)
        created_resources = monitor_task(response.task).created_resources
        content_unit = self.content_api.read(created_resources[0])

        # Packages types only validate the filename, so we can prepend something to the path.
        attrs["relative_path"] = "moved-" + content_unit.relative_path
        # create second content unit.
        response = self.content_api.create(**attrs)
        created_resources = monitor_task(response.task).created_resources
        content_unit = self.content_api.read(created_resources[0])
Пример #3
0
 def setUpClass(cls):
     """Create class-wide variable."""
     delete_orphans()
     cls.content_unit = {}
     cls.artifact = gen_artifact(cls.CONTENT_URL)