Пример #1
0
class RemoteManagerTest(unittest.TestCase):
    """Unit test"""
    def setUp(self):
        self.conan_reference = ConanFileReference.loads(
            "openssl/2.0.3@lasote/testing")
        self.package_reference = PackageReference(self.conan_reference,
                                                  "123123123")
        self.remote_client = MockRemoteClient()
        self.output = TestBufferConanOutput()
        self.client_cache = ClientCache(temp_folder(), temp_folder(),
                                        self.output)
        self.manager = RemoteManager(self.client_cache, self.remote_client,
                                     self.output)

    def test_no_remotes(self):
        client = TestClient()
        files = cpp_hello_conan_files("Hello0", "0.1")
        client.save(files)
        client.run("export lasote/stable")
        client.run("upload Hello0/0.1@lasote/stable", ignore_error=True)
        self.assertIn("ERROR: No default remote defined", client.user_io.out)

    def method_called_test(self):

        save(
            os.path.join(self.client_cache.package(self.package_reference),
                         CONANINFO), "asdasd")
        manifest = FileTreeManifest.create(
            self.client_cache.package(self.package_reference))
        save(
            os.path.join(self.client_cache.package(self.package_reference),
                         CONAN_MANIFEST), str(manifest))

        self.assertFalse(self.remote_client.upload_package.called)
        self.manager.upload_package(self.package_reference,
                                    Remote("other", "url", True), 1, 0)
        self.assertTrue(self.remote_client.upload_package.called)

        self.assertFalse(self.remote_client.get_conan_digest.called)
        self.manager.get_conan_digest(self.conan_reference,
                                      Remote("other", "url", True))
        self.assertTrue(self.remote_client.get_conan_digest.called)

        self.assertFalse(self.remote_client.get_recipe.called)
        self.manager.get_recipe(self.conan_reference, temp_folder(),
                                Remote("other", "url", True))
        self.assertTrue(self.remote_client.get_recipe.called)

        self.assertFalse(self.remote_client.get_package.called)
        self.manager.get_package(self.package_reference, temp_folder(),
                                 Remote("other", "url", True))
        self.assertTrue(self.remote_client.get_package.called)
Пример #2
0
class RemoteManagerTest(unittest.TestCase):
    """Unit test"""

    def setUp(self):
        self.conan_reference = ConanFileReference.loads("openssl/2.0.3@lasote/testing")
        self.package_reference = PackageReference(self.conan_reference, "123123123")
        self.remote_client = MockRemoteClient()
        self.output = TestBufferConanOutput()
        self.client_cache = ClientCache(temp_folder(), temp_folder(), self.output)
        self.remotes = [("default", "url1"), ("other", "url2"), ("last", "url3")]
        self.manager = RemoteManager(self.client_cache, self.remote_client, self.output)

    def test_no_remotes(self):
        client = TestClient()
        files = cpp_hello_conan_files("Hello0", "0.1")
        client.save(files)
        client.run("export lasote/stable")
        client.run("upload Hello0/0.1@lasote/stable", ignore_error=True)
        self.assertIn("ERROR: No default remote defined", client.user_io.out)

    def remote_selection_test(self):
        save(os.path.join(self.client_cache.export(self.conan_reference), CONANFILE), "asdasd")
        save(os.path.join(self.client_cache.export(self.conan_reference), CONAN_MANIFEST), "asdasd")

        # If no remote is specified will look to first
        self.assertRaises(NotFoundException, self.manager.upload_conan, self.conan_reference, None)

        # If remote is specified took it
        self.assertRaises(NotFoundException,
                          self.manager.upload_conan, self.conan_reference, Remote("other", "url"))

    def method_called_test(self):

        save(os.path.join(self.client_cache.package(self.package_reference), CONANINFO), "asdasd")
        manifest = FileTreeManifest.create(self.client_cache.package(self.package_reference))
        save(os.path.join(self.client_cache.package(self.package_reference), CONAN_MANIFEST), str(manifest))

        self.assertFalse(self.remote_client.upload_package.called)
        self.manager.upload_package(self.package_reference, Remote("other", "url"))
        self.assertTrue(self.remote_client.upload_package.called)

        self.assertFalse(self.remote_client.get_conan_digest.called)
        self.manager.get_conan_digest(self.conan_reference, Remote("other", "url"))
        self.assertTrue(self.remote_client.get_conan_digest.called)

        self.assertFalse(self.remote_client.get_recipe.called)
        self.manager.get_recipe(self.conan_reference, temp_folder(), Remote("other", "url"))
        self.assertTrue(self.remote_client.get_recipe.called)

        self.assertFalse(self.remote_client.get_package.called)
        self.manager.get_package(self.package_reference, temp_folder(), Remote("other", "url"))
        self.assertTrue(self.remote_client.get_package.called)
Пример #3
0
class RemoteManagerTest(unittest.TestCase):
    """Unit test"""
    def setUp(self):
        self.conan_reference = ConanFileReference.loads(
            "openssl/2.0.3@lasote/testing")
        self.package_reference = PackageReference(self.conan_reference,
                                                  "123123123")
        self.remote_client = MockRemoteClient()
        self.output = TestBufferConanOutput()
        self.paths = ConanPaths(temp_folder(), temp_folder(), self.output)
        self.remotes = [("default", "url1"), ("other", "url2"),
                        ("last", "url3")]
        self.manager = RemoteManager(self.paths, self.remote_client,
                                     self.output)

    def test_no_remotes(self):
        client = TestClient()
        files = cpp_hello_conan_files("Hello0", "0.1")
        client.save(files)
        client.run("export lasote/stable")
        client.run("upload Hello0/0.1@lasote/stable", ignore_error=True)
        self.assertIn("ERROR: No default remote defined", client.user_io.out)

    def remote_selection_test(self):
        # If no remote is specified will look to first
        self.assertRaises(NotFoundException, self.manager.upload_conan,
                          self.conan_reference, Remote("other", "url"))

        # If remote is specified took it
        self.assertRaises(NotFoundException, self.manager.upload_conan,
                          self.conan_reference, Remote("other", "url"))

    def method_called_test(self):
        self.assertFalse(self.remote_client.upload_package.called)
        self.manager.upload_package(self.package_reference,
                                    Remote("other", "url"))
        self.assertTrue(self.remote_client.upload_package.called)

        self.assertFalse(self.remote_client.get_conan_digest.called)
        self.manager.get_conan_digest(self.conan_reference,
                                      Remote("other", "url"))
        self.assertTrue(self.remote_client.get_conan_digest.called)

        self.assertFalse(self.remote_client.get_conanfile.called)
        self.manager.get_conanfile(self.conan_reference,
                                   Remote("other", "url"))
        self.assertTrue(self.remote_client.get_conanfile.called)

        self.assertFalse(self.remote_client.get_package.called)
        self.manager.get_package(self.package_reference,
                                 Remote("other", "url"))
        self.assertTrue(self.remote_client.get_package.called)
Пример #4
0
class RemoteManagerTest(unittest.TestCase):
    """Unit test"""

    def setUp(self):
        self.conan_reference = ConanFileReference.loads("openssl/2.0.3@lasote/testing")
        self.package_reference = PackageReference(self.conan_reference, "123123123")
        self.remote_client = MockRemoteClient()
        self.output = TestBufferConanOutput()
        self.paths = ConanPaths(temp_folder(), temp_folder(), self.output)
        self.remotes = [("default", "url1"), ("other", "url2"), ("last", "url3")]
        self.manager = RemoteManager(self.paths, self.remotes, self.remote_client, self.output)

    def test_no_remotes(self):
        client = TestClient()
        files = cpp_hello_conan_files("Hello0", "0.1")
        client.save(files)
        client.run("export lasote/stable")
        client.run("upload Hello0/0.1@lasote/stable", ignore_error=True)
        self.assertIn("ERROR: There is no configured default remote", client.user_io.out)

    def test_properties(self):
        # Remote names
        self.assertEquals(self.manager.remote_names, ["default", "other", "last"])
        # Remote url
        self.assertEquals(self.manager.remote_url("default"), "url1")
        self.assertEquals(self.manager.remote_url("other"), "url2")

    def remote_selection_test(self):
        # If no remote is specified will look to first
        self.assertRaises(NotFoundException, self.manager.upload_conan, self.conan_reference)

        # If remote is specified took it
        self.assertRaises(NotFoundException,
                          self.manager.upload_conan, self.conan_reference, "other")

    def method_called_test(self):
        self.assertFalse(self.remote_client.upload_package.called)
        self.manager.upload_package(self.package_reference, "other")
        self.assertTrue(self.remote_client.upload_package.called)

        self.assertFalse(self.remote_client.get_conan_digest.called)
        self.manager.get_conan_digest(self.conan_reference)
        self.assertTrue(self.remote_client.get_conan_digest.called)

        self.assertFalse(self.remote_client.get_conanfile.called)
        self.manager.get_conanfile(self.conan_reference)
        self.assertTrue(self.remote_client.get_conanfile.called)

        self.assertFalse(self.remote_client.get_package.called)
        self.manager.get_package(self.package_reference)
        self.assertTrue(self.remote_client.get_package.called)
Пример #5
0
class RemoteManagerTest(unittest.TestCase):
    """Unit test"""
    def setUp(self):
        self.conan_reference = ConanFileReference.loads(
            "openssl/2.0.3@lasote/testing")
        self.package_reference = PackageReference(self.conan_reference,
                                                  "123123123")
        self.remote_client = MockRemoteClient()
        self.output = TestBufferConanOutput()
        self.paths = ConanPaths(temp_folder(), None, self.output)
        self.remotes = [("default", "url1"), ("other", "url2"),
                        ("last", "url3")]
        self.manager = RemoteManager(self.paths, self.remotes,
                                     self.remote_client, self.output)

    def test_properties(self):
        # Remote names
        self.assertEquals(self.manager.remote_names,
                          ["default", "other", "last"])
        # Remote url
        self.assertEquals(self.manager.remote_url("default"), "url1")
        self.assertEquals(self.manager.remote_url("other"), "url2")

    def remote_selection_test(self):
        # If no remote is specified will look to first
        self.assertRaises(NotFoundException, self.manager.upload_conan,
                          self.conan_reference)

        # If remote is specified took it
        self.assertRaises(NotFoundException, self.manager.upload_conan,
                          self.conan_reference, "other")

    def method_called_test(self):
        self.assertFalse(self.remote_client.upload_package.called)
        self.manager.upload_package(self.package_reference, "other")
        self.assertTrue(self.remote_client.upload_package.called)

        self.assertFalse(self.remote_client.get_conan_digest.called)
        self.manager.get_conan_digest(self.conan_reference)
        self.assertTrue(self.remote_client.get_conan_digest.called)

        self.assertFalse(self.remote_client.get_conanfile.called)
        self.manager.get_conanfile(self.conan_reference)
        self.assertTrue(self.remote_client.get_conanfile.called)

        self.assertFalse(self.remote_client.get_package.called)
        self.manager.get_package(self.package_reference)
        self.assertTrue(self.remote_client.get_package.called)
Пример #6
0
class RemoteManagerTest(unittest.TestCase):
    """Unit test"""

    def setUp(self):
        self.conan_reference = ConanFileReference.loads("openssl/2.0.3@lasote/testing")
        self.package_reference = PackageReference(self.conan_reference, "123123123")
        self.remote_client = MockRemoteClient()
        self.output = TestBufferConanOutput()
        self.paths = ConanPaths(temp_folder(), None, self.output)
        self.remotes = [("default", "url1"), ("other", "url2"), ("last", "url3")]
        self.manager = RemoteManager(self.paths, self.remotes, self.remote_client, self.output)

    def test_properties(self):
        # Remote names
        self.assertEquals(self.manager.remote_names, ["default", "other", "last"])
        # Remote url
        self.assertEquals(self.manager.remote_url("default"), "url1")
        self.assertEquals(self.manager.remote_url("other"), "url2")

    def remote_selection_test(self):
        # If no remote is specified will look to first
        self.assertRaises(NotFoundException, self.manager.upload_conan, self.conan_reference)

        # If remote is specified took it
        self.assertRaises(NotFoundException,
                          self.manager.upload_conan, self.conan_reference, "other")

    def method_called_test(self):
        self.assertFalse(self.remote_client.upload_package.called)
        self.manager.upload_package(self.package_reference, "other")
        self.assertTrue(self.remote_client.upload_package.called)

        self.assertFalse(self.remote_client.get_conan_digest.called)
        self.manager.get_conan_digest(self.conan_reference)
        self.assertTrue(self.remote_client.get_conan_digest.called)

        self.assertFalse(self.remote_client.get_conanfile.called)
        self.manager.get_conanfile(self.conan_reference)
        self.assertTrue(self.remote_client.get_conanfile.called)

        self.assertFalse(self.remote_client.get_package.called)
        self.manager.get_package(self.package_reference)
        self.assertTrue(self.remote_client.get_package.called)