Пример #1
0
    def upload(self, pattern, package=None, remote_name=None, all_packages=False, confirm=False,
               retry=2, retry_wait=5, integrity_check=False, policy=None, query=None):
        """ Uploads a package recipe and the generated binary packages to a specified remote
        """

        recorder = UploadRecorder()
        uploader = CmdUpload(self._client_cache, self._user_io, self._remote_manager,
                             self._registry, self._loader, self._plugin_manager)
        try:
            uploader.upload(recorder, pattern, package, all_packages, confirm, retry,
                            retry_wait, integrity_check, policy, remote_name, query=query)
            return recorder.get_info()
        except ConanException as exc:
            recorder.error = True
            exc.info = recorder.get_info()
            raise
Пример #2
0
    def upload(self, pattern, package=None, remote_name=None,
               all_packages=False, force=False, confirm=False, retry=2,
               retry_wait=5, skip_upload=False, integrity_check=False,
               no_overwrite=None, query=None):
        """ Uploads a package recipe and the generated binary packages to a specified remote
        """

        recorder = UploadRecorder()

        if force and no_overwrite:
            exc = ConanException("'no_overwrite' argument cannot be used together with 'force'")
            recorder.error = True
            exc.info = recorder.get_info()
            raise exc

        uploader = CmdUpload(self._client_cache, self._user_io, self._remote_manager,
                             self._registry, self._loader)
        try:
            uploader.upload(recorder, pattern, package, all_packages, force, confirm, retry,
                            retry_wait, skip_upload, integrity_check, no_overwrite, remote_name,
                            query=query)
            return recorder.get_info()
        except ConanException as exc:
            recorder.error = True
            exc.info = recorder.get_info()
            raise
Пример #3
0
 def setUp(self):
     self.upload_recorder = UploadRecorder()
Пример #4
0
class UploadRecorderTest(unittest.TestCase):
    def setUp(self):
        self.upload_recorder = UploadRecorder()

    def test_empty(self):
        info = self.upload_recorder.get_info()
        expected_result = {'error': False, 'uploaded': []}
        self.assertEqual(expected_result, info)

    def test_sequential(self):
        ref = ConanFileReference.loads("fake/0.1@user/channel#rev")
        ref2 = ConanFileReference.loads("fakefake/0.1@user/channel")
        self.upload_recorder.add_recipe(ref, "my_remote",
                                        "https://fake_url.com")
        pref1 = PackageReference(ref, "fake_package_id", "prev")
        self.upload_recorder.add_package(pref1, "my_remote",
                                         "https://fake_url.com")
        self.upload_recorder.add_recipe(ref2, "my_remote2",
                                        "https://fake_url2.com")
        self.upload_recorder.add_package(
            PackageReference(ref2, "fakefake_package_id1"), "my_remote",
            "https://fake_url.com")
        self.upload_recorder.add_package(
            PackageReference(ref2, "fakefake_package_id2"), "my_remote",
            "https://fake_url.com")
        info = self.upload_recorder.get_info()
        expected_result_without_time = {
            "error":
            False,
            "uploaded": [{
                "recipe": {
                    "id": "fake/0.1@user/channel",
                    "remote_name": "my_remote",
                    "remote_url": "https://fake_url.com",
                    "revision": "rev"
                },
                "packages": [{
                    "id": "fake_package_id",
                    "remote_name": "my_remote",
                    "remote_url": "https://fake_url.com",
                    "revision": "prev"
                }]
            }, {
                "recipe": {
                    "id": "fakefake/0.1@user/channel",
                    "remote_name": "my_remote2",
                    "remote_url": "https://fake_url2.com",
                },
                "packages": [{
                    "id": "fakefake_package_id1",
                    "remote_name": "my_remote",
                    "remote_url": "https://fake_url.com"
                }, {
                    "id": "fakefake_package_id2",
                    "remote_name": "my_remote",
                    "remote_url": "https://fake_url.com"
                }]
            }]
        }
        self._check_result(expected_result_without_time, info)

    def test_unordered(self):
        ref1 = ConanFileReference.loads("fake1/0.1@user/channel")
        ref2 = ConanFileReference.loads("fake2/0.1@user/channel")
        ref3 = ConanFileReference.loads("fake3/0.1@user/channel")
        self.upload_recorder.add_recipe(ref1, "my_remote1",
                                        "https://fake_url1.com")
        self.upload_recorder.add_recipe(ref2, "my_remote2",
                                        "https://fake_url2.com")
        self.upload_recorder.add_recipe(ref3, "my_remote3",
                                        "https://fake_url3.com")
        self.upload_recorder.add_package(
            PackageReference(ref1, "fake1_package_id1"), "my_remote1",
            "https://fake_url1.com")
        self.upload_recorder.add_package(
            PackageReference(ref2, "fake2_package_id1"), "my_remote2",
            "https://fake_url2.com")
        self.upload_recorder.add_package(
            PackageReference(ref2, "fake2_package_id2"), "my_remote2",
            "https://fake_url2.com")
        info = self.upload_recorder.get_info()
        expected_result_without_time = {
            "error":
            False,
            "uploaded": [{
                "recipe": {
                    "id": "fake1/0.1@user/channel",
                    "remote_name": "my_remote1",
                    "remote_url": "https://fake_url1.com"
                },
                "packages": [{
                    "id": "fake1_package_id1",
                    "remote_name": "my_remote1",
                    "remote_url": "https://fake_url1.com"
                }]
            }, {
                "recipe": {
                    "id": "fake2/0.1@user/channel",
                    "remote_name": "my_remote2",
                    "remote_url": "https://fake_url2.com"
                },
                "packages": [{
                    "id": "fake2_package_id1",
                    "remote_name": "my_remote2",
                    "remote_url": "https://fake_url2.com"
                }, {
                    "id": "fake2_package_id2",
                    "remote_name": "my_remote2",
                    "remote_url": "https://fake_url2.com"
                }]
            }, {
                "recipe": {
                    "id": "fake3/0.1@user/channel",
                    "remote_name": "my_remote3",
                    "remote_url": "https://fake_url3.com"
                },
                "packages": []
            }]
        }
        self._check_result(expected_result_without_time, info)

    def _check_result(self, expected, result):
        for i, item in enumerate(result["uploaded"]):
            assert item["recipe"]["time"]
            del result["uploaded"][i]["recipe"]["time"]

            for j, package in enumerate(item["packages"]):
                assert package["time"], datetime
                del result["uploaded"][i]["packages"][j]["time"]
        self.assertEqual(expected, result)
Пример #5
0
class UploadRecorderTest(unittest.TestCase):
    def setUp(self):
        self.recorder = UploadRecorder()

    def empty_test(self):
        info = self.recorder.get_info()
        expected_result = {'error': False, 'uploaded': []}
        self.assertEqual(expected_result, info)

    def sequential_test(self):
        self.recorder.add_recipe("fake/0.1@user/channel", "my_remote",
                                 "https://fake_url.com")
        self.recorder.add_package("fake/0.1@user/channel", "fake_package_id")
        self.recorder.add_recipe("fakefake/0.1@user/channel", "my_remote2",
                                 "https://fake_url2.com")
        self.recorder.add_package("fakefake/0.1@user/channel",
                                  "fakefake_package_id1")
        self.recorder.add_package("fakefake/0.1@user/channel",
                                  "fakefake_package_id2")
        info = self.recorder.get_info()
        expected_result_without_time = {
            "error":
            False,
            "uploaded": [{
                "recipe": {
                    "id": "fake/0.1@user/channel",
                    "remote_name": "my_remote",
                    "remote_url": "https://fake_url.com"
                },
                "packages": [{
                    "id": "fake_package_id"
                }]
            }, {
                "recipe": {
                    "id": "fakefake/0.1@user/channel",
                    "remote_name": "my_remote2",
                    "remote_url": "https://fake_url2.com"
                },
                "packages": [{
                    "id": "fakefake_package_id1"
                }, {
                    "id": "fakefake_package_id2"
                }]
            }]
        }

        self._check_result(expected_result_without_time, info)

    def unordered_test(self):
        self.recorder.add_recipe("fake1/0.1@user/channel", "my_remote1",
                                 "https://fake_url1.com")
        self.recorder.add_recipe("fake2/0.1@user/channel", "my_remote2",
                                 "https://fake_url2.com")
        self.recorder.add_recipe("fake3/0.1@user/channel", "my_remote3",
                                 "https://fake_url3.com")
        self.recorder.add_package("fake1/0.1@user/channel",
                                  "fake1_package_id1")
        self.recorder.add_package("fake2/0.1@user/channel",
                                  "fake2_package_id1")
        self.recorder.add_package("fake2/0.1@user/channel",
                                  "fake2_package_id2")
        info = self.recorder.get_info()
        expected_result_without_time = {
            "error":
            False,
            "uploaded": [{
                "recipe": {
                    "id": "fake1/0.1@user/channel",
                    "remote_name": "my_remote1",
                    "remote_url": "https://fake_url1.com"
                },
                "packages": [{
                    "id": "fake1_package_id1"
                }]
            }, {
                "recipe": {
                    "id": "fake2/0.1@user/channel",
                    "remote_name": "my_remote2",
                    "remote_url": "https://fake_url2.com"
                },
                "packages": [{
                    "id": "fake2_package_id1"
                }, {
                    "id": "fake2_package_id2"
                }]
            }, {
                "recipe": {
                    "id": "fake3/0.1@user/channel",
                    "remote_name": "my_remote3",
                    "remote_url": "https://fake_url3.com"
                },
                "packages": []
            }]
        }

        self._check_result(expected_result_without_time, info)

    def _check_result(self, expeceted, result):
        for i, item in enumerate(result["uploaded"]):
            assert item["recipe"]["time"]
            del result["uploaded"][i]["recipe"]["time"]

            for j, package in enumerate(item["packages"]):
                assert package["time"], datetime
                del result["uploaded"][i]["packages"][j]["time"]
        self.assertEqual(expeceted, result)