def retro_compatibility_test(self): folder = temp_folder() f = os.path.join(folder, ".conan", "registry.txt") save(f, "conan.io https://server.conan.io") # Without SSL parameter cache = ClientCache(folder, TestBufferConanOutput()) migrate_registry_file(cache, TestBufferConanOutput()) registry = RemoteRegistry(cache) self.assertEqual(list(registry.load_remotes().values()), [("conan.io", "https://server.conan.io", True)])
def retro_compatibility_test(self): folder = temp_folder() f = os.path.join(folder, "registry.txt") save(f, textwrap.dedent("""conan.io https://server.conan.io pkg/0.1@user/testing some_remote """)) output = TestBufferConanOutput() cache = ClientCache(folder, output) migrate_registry_file(cache, output) registry = RemoteRegistry(cache, output) self.assertEqual(list(registry.load_remotes().values()), [("conan.io", "https://server.conan.io", True, False)])
def insert_test(self): f = os.path.join(temp_folder(), "aux_file") save( f, """ { "remotes": [ { "url": "https://server.conan.io", "verify_ssl": true, "name": "conan.io" } ], "references": {} } """) registry = RemoteRegistry(f, TestBufferConanOutput()) registry.remotes.add("repo1", "url1", True, insert=0) self.assertEqual(registry.remotes.list, [("repo1", "url1", True), ("conan.io", "https://server.conan.io", True)]) registry.remotes.add("repo2", "url2", True, insert=1) self.assertEqual(registry.remotes.list, [("repo1", "url1", True), ("repo2", "url2", True), ("conan.io", "https://server.conan.io", True)]) registry.remotes.add("repo3", "url3", True, insert=5) self.assertEqual(registry.remotes.list, [("repo1", "url1", True), ("repo2", "url2", True), ("conan.io", "https://server.conan.io", True), ("repo3", "url3", True)])
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())
def retro_compatibility_test(self): f = os.path.join(temp_folder(), "aux_file") save(f, """conan.io https://server.conan.io """) # Without SSL parameter new_path = os.path.join(temp_folder(), "aux_file.json") migrate_registry_file(f, new_path) registry = RemoteRegistry(new_path, TestBufferConanOutput()) self.assertEqual(registry.remotes.list, [("conan.io", "https://server.conan.io", True)])
def registry(self): if not self._registry: remotes_path = self.registry_path if not os.path.exists(remotes_path): self._output.warn("Remotes registry file missing, " "creating default one in %s" % remotes_path) remotes = Remotes.defaults() remotes.save(remotes_path) self._registry = RemoteRegistry(self) return self._registry
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])
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")
def registry(self): return RemoteRegistry(self, self._output)
def registry(self): if not self._registry: self._registry = RemoteRegistry(self.registry_path, self._output) return self._registry
def insert_test(self): tmp_folder = temp_folder() f = os.path.join(tmp_folder, "remotes.json") save( f, """ { "remotes": [ { "url": "https://server.conan.io", "verify_ssl": true, "name": "conan.io" } ] } """) output = TestBufferConanOutput() cache = ClientCache(tmp_folder, output) registry = RemoteRegistry(cache, output) registry.add("repo1", "url1", True, insert=0) self.assertEqual(list(registry.load_remotes().values()), [ Remote("repo1", "url1", True, False), Remote("conan.io", "https://server.conan.io", True, False) ]) registry.add("repo2", "url2", True, insert=1) self.assertEqual(list(registry.load_remotes().values()), [ Remote("repo1", "url1", True, False), Remote("repo2", "url2", True, False), Remote("conan.io", "https://server.conan.io", True, False) ]) registry.add("repo3", "url3", True, insert=5) self.assertEqual(list(registry.load_remotes().values()), [ Remote("repo1", "url1", True, False), Remote("repo2", "url2", True, False), Remote("conan.io", "https://server.conan.io", True, False), Remote("repo3", "url3", True, False) ])