Beispiel #1
0
 def _get_registry():
     f = os.path.join(temp_folder(), "aux_file")
     remotes, refs = load_registry_txt(
         "conan.io https://server.conan.io True\n"
         "conan.io2 https://server2.conan.io True\n")
     reg = dump_registry(remotes, refs, {})
     save(f, reg)
     return RemoteRegistry(f, TestBufferConanOutput())
Beispiel #2
0
 def registry_path(self):
     reg_json_path = join(self.conan_folder, REGISTRY_JSON)
     if not os.path.exists(reg_json_path):
         # Load the txt if exists and convert to json
         reg_txt = join(self.conan_folder, REGISTRY)
         if os.path.exists(reg_txt):
             migrate_registry_file(reg_txt, reg_json_path)
         else:
             self._output.warn("Remotes registry file missing, "
                               "creating default one in %s" % reg_json_path)
             save(reg_json_path, dump_registry(default_remotes, {}, {}))
     return reg_json_path
Beispiel #3
0
    def refs_test(self):
        f = os.path.join(temp_folder(), "aux_file")
        save(f, dump_registry(default_remotes, {}, {}))
        registry = RemoteRegistry(f, TestBufferConanOutput())
        ref = ConanFileReference.loads("MyLib/0.1@lasote/stable")

        remotes = registry.remotes.list
        registry.refs.set(ref, remotes[0].name)
        remote = registry.refs.get(ref)
        self.assertEqual(remote, remotes[0])

        registry.refs.set(ref, remotes[0].name)
        remote = registry.refs.get(ref)
        self.assertEqual(remote, remotes[0])
Beispiel #4
0
    def update_servers(self):
        save(self.cache.registry_path, dump_registry({}, {}, {}))
        registry = self.cache.registry

        def add_server_to_registry(name, server):
            if isinstance(server, TestServer):
                registry.remotes.add(name, server.fake_url)
            else:
                registry.remotes.add(name, server)

        for name, server in self.servers.items():
            if name == "default":
                add_server_to_registry(name, server)

        for name, server in self.servers.items():
            if name != "default":
                add_server_to_registry(name, server)
Beispiel #5
0
    def add_remove_update_test(self):
        f = os.path.join(temp_folder(), "aux_file")
        save(f, dump_registry(default_remotes, {}, {}))
        registry = RemoteRegistry(f, TestBufferConanOutput())

        # Add
        registry.remotes.add("local", "http://localhost:9300")
        self.assertEqual(registry.remotes.list,
                         [("conan-center", "https://conan.bintray.com", True),
                          ("local", "http://localhost:9300", True)])
        # Add
        registry.remotes.add("new", "new_url", False)
        self.assertEqual(registry.remotes.list,
                         [("conan-center", "https://conan.bintray.com", True),
                          ("local", "http://localhost:9300", True),
                          ("new", "new_url", False)])
        with self.assertRaises(ConanException):
            registry.remotes.add("new", "new_url")
        # Update
        registry.remotes.update("new", "other_url")
        self.assertEqual(registry.remotes.list,
                         [("conan-center", "https://conan.bintray.com", True),
                          ("local", "http://localhost:9300", True),
                          ("new", "other_url", True)])
        with self.assertRaises(ConanException):
            registry.remotes.update("new2", "new_url")

        registry.remotes.update("new", "other_url", False)
        self.assertEqual(registry.remotes.list,
                         [("conan-center", "https://conan.bintray.com", True),
                          ("local", "http://localhost:9300", True),
                          ("new", "other_url", False)])

        # Remove
        registry.remotes.remove("local")
        self.assertEqual(registry.remotes.list,
                         [("conan-center", "https://conan.bintray.com", True),
                          ("new", "other_url", False)])
        with self.assertRaises(ConanException):
            registry.remotes.remove("new2")
Beispiel #6
0
    def update_servers(self):
        save(self.cache.registry_path, dump_registry({}, {}, {}))
        registry = self.cache.registry

        def add_server_to_registry(name, server):
            if isinstance(server, ArtifactoryServer):
                registry.remotes.add(name, server.repo_api_url)
                self.users.update({
                    name:
                    [(ARTIFACTORY_DEFAULT_USER, ARTIFACTORY_DEFAULT_PASSWORD)]
                })
            elif isinstance(server, TestServer):
                registry.remotes.add(name, server.fake_url)
            else:
                registry.remotes.add(name, server)

        for name, server in self.servers.items():
            if name == "default":
                add_server_to_registry(name, server)

        for name, server in self.servers.items():
            if name != "default":
                add_server_to_registry(name, server)