示例#1
0
def test_pypicloud_get_versions_with_exclude(mocker, os_environ):
    mocker.patch("pypicloud_client.client.request_factory", autospec=True,
                 return_value={
                     "packages": [
                         {
                             "name": "flywheel",
                             "last_modified": 1389945600,
                             "version": "0.1.0",
                             "url": "https://pypi.s3.amazonaws.com/34c2/flywheel-0.1.0.tar.gz"
                         },
                         {
                             "name": "flywheel",
                             "last_modified": 1390207478,
                             "version": "0.1.0-21-g4a739b0",
                             "url": "https://pypi.s3.amazonaws.com/81f2/flywheel-0.1.0-21-g4a739b0.tar.gz"
                         }
                     ],
                     "write": True
                 })

    pypicloud_with_kwargs = PypicloudClient(host="host", user="******", password="******")

    versions0 = pypicloud_with_kwargs.get_versions("flywheel", filters={"version": "0.1.0-21"}, exclude=True)
    assert versions0 == [
        {
         "name": "flywheel",
         "last_modified": 1389945600,
         "version": "0.1.0",
         "url": "https://pypi.s3.amazonaws.com/34c2/flywheel-0.1.0.tar.gz"
        }
         ]
示例#2
0
def test_pypicloud_delete_version_no_filename(mocker, monkeypatch, os_environ):
    monkeypatch.setattr(PypicloudClient, "get_versions", lambda *args: [])

    mocker.patch("pypicloud_client.client.request_factory")

    pypicloud_client = PypicloudClient()

    pypicloud_client.delete_package("flywheel", "0.1.0-21-g4a739b0")
示例#3
0
def test_pypicloud_delete_version(mocker, monkeypatch, os_environ):
    monkeypatch.setattr(PypicloudClient, "get_versions", lambda *args: [
        {
            "name": "flywheel",
            "last_modified": 1389945600,
            "version": "0.1.0",
            "url": "https://pypi.s3.amazonaws.com/34c2/",
            "filename": "flywheel-0.1.0.tar.gz"
        },
        {
            "name": "flywheel",
            "last_modified": 1390207478,
            "version": "0.1.0-21-g4a739b0",
            "url": "https://pypi.s3.amazonaws.com/81f2/flywheel-0.1.0-21-g4a739b0.tar.gz",
            "filename": "flywheel-0.1.0-21-g4a739b0.tar.gz"
        }])

    mocker.patch("pypicloud_client.client.request_factory")

    pypicloud_client = PypicloudClient()
    pypicloud_client.delete_package("flywheel", "0.1.0-21-g4a739b0")
示例#4
0
文件: whl.py 项目: Dudesons/loktar
        def __init__(self, artifact_info, remote):
            """Plugin for building python wheel package

                Args:
                    artifact_info (dict): Contains information about the package to execute inside the plugin
                    remote (bool): Define if the plugin will be execute in remote or not

                Raises:
                    CIBuildPackageFail: when one of the steps for packaging or uploading the package failed
            """
            ComplexPlugin.__init__(self, artifact_info,
                                   {
                                       "command": {
                                           "run": None,
                                           "clean": artifact_info.get("clean_method", "make clean")
                                       }
                                   },
                                   remote=remote)
            self.timeline = {
                10: self.get_next_version,
                40: self.release
            }
            self.pypicloud = PypicloudClient()
示例#5
0
文件: whl.py 项目: Dudesons/loktar
class Whl(ComplexPlugin):
        def __init__(self, artifact_info, remote):
            """Plugin for building python wheel package

                Args:
                    artifact_info (dict): Contains information about the package to execute inside the plugin
                    remote (bool): Define if the plugin will be execute in remote or not

                Raises:
                    CIBuildPackageFail: when one of the steps for packaging or uploading the package failed
            """
            ComplexPlugin.__init__(self, artifact_info,
                                   {
                                       "command": {
                                           "run": None,
                                           "clean": artifact_info.get("clean_method", "make clean")
                                       }
                                   },
                                   remote=remote)
            self.timeline = {
                10: self.get_next_version,
                40: self.release
            }
            self.pypicloud = PypicloudClient()

        def run(self):
            """Default method for running the timeline

            """
            self._run()
            return {
                "version": self.share_memory["latest_version"]
            }

        def get_next_version(self):
            """Get the next version for the current package

            """
            if self.artifact_info["mode"] == "master":
                try:
                    versions = filter(
                        lambda pkg_version: int(pkg_version.isdigit()),
                        map(
                            lambda pkg: pkg["version"],
                            self.pypicloud.get_versions(self.artifact_info["artifact_name"])
                        )
                    )

                    self.share_memory["latest_version"] = str(
                        sorted(
                            [int(version) for version in versions],
                            reverse=True
                        )[0] + 1
                    )

                except IndexError:
                    self.share_memory["latest_version"] = 1
            else:
                self.artifact_info["mode"] = self.artifact_info["mode"].replace("_", "-").replace("/", "-")
                self.share_memory["latest_version"] = "0.{0}".format(self.artifact_info["mode"])
                self.pypicloud.delete_package(self.artifact_info["artifact_name"], self.share_memory["latest_version"])

        @retry
        def release(self):
            """Create & upload the package

            """
            with self.cwd(self.path):
                # Edit the package version
                if not exe("sed -i 's/VERSION = .*/VERSION = \"{0}\"/g' setup.py"
                           .format(self.share_memory["latest_version"]), remote=self.remote):
                    raise CIBuildPackageFail("Failed to update the version")

                # Build package
                if not exe("make release", remote=self.remote):
                    raise CIBuildPackageFail("Release failed for the wheel package")

                self.logger.info("Wheel package built & uploaded")