Ejemplo n.º 1
0
    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)])
Ejemplo n.º 2
0
 def _check(self, params):
     typ, uri, verify, args = [p.strip() for p in params.split(",")]
     configs = json.loads(load(self.client.cache.config_install_file))
     config = _ConfigOrigin(configs[0])
     self.assertEqual(config.type, typ)
     self.assertEqual(config.uri, uri)
     self.assertEqual(str(config.verify_ssl), verify)
     self.assertEqual(str(config.args), args)
     settings_path = self.client.cache.settings_path
     self.assertEqual(load(settings_path).splitlines(), settings_yml.splitlines())
     remotes = self.client.cache.registry.load_remotes()
     self.assertEqual(list(remotes.values()), [
         Remote("myrepo1", "https://myrepourl.net", False, False),
         Remote("my-repo-2", "https://myrepo2.com", True, False),
     ])
     self.assertEqual(sorted(os.listdir(self.client.cache.profiles_path)),
                      sorted(["default", "linux", "windows"]))
     self.assertEqual(load(os.path.join(self.client.cache.profiles_path, "linux")).splitlines(),
                      linux_profile.splitlines())
     self.assertEqual(load(os.path.join(self.client.cache.profiles_path,
                                        "windows")).splitlines(),
                      win_profile.splitlines())
     conan_conf = ConanClientConfigParser(self.client.cache.conan_conf_path)
     self.assertEqual(conan_conf.get_item("log.run_to_output"), "False")
     self.assertEqual(conan_conf.get_item("log.run_to_file"), "False")
     self.assertEqual(conan_conf.get_item("log.level"), "10")
     self.assertEqual(conan_conf.get_item("general.compression_level"), "6")
     self.assertEqual(conan_conf.get_item("general.default_package_id_mode"),
                      "full_package_mode")
     self.assertEqual(conan_conf.get_item("general.sysrequires_sudo"), "True")
     self.assertEqual(conan_conf.get_item("general.cpu_count"), "1")
     with six.assertRaisesRegex(self, ConanException, "'config_install' doesn't exist"):
         conan_conf.get_item("general.config_install")
     self.assertEqual(conan_conf.get_item("proxies.https"), "None")
     self.assertEqual(conan_conf.get_item("proxies.http"), "http://*****:*****@10.10.1.10:3128/")
     self.assertEqual("#Custom pylint",
                      load(os.path.join(self.client.cache_folder, "pylintrc")))
     self.assertEqual("",
                      load(os.path.join(self.client.cache_folder, "python",
                                        "__init__.py")))
     self.assertEqual("#hook dummy",
                      load(os.path.join(self.client.cache_folder, "hooks", "dummy")))
     self.assertEqual("#hook foo",
                      load(os.path.join(self.client.cache_folder, "hooks", "foo.py")))
     self.assertEqual("#hook custom",
                      load(os.path.join(self.client.cache_folder, "hooks", "custom",
                                        "custom.py")))
     self.assertFalse(os.path.exists(os.path.join(self.client.cache_folder, "hooks",
                                                  ".git")))
     self.assertFalse(os.path.exists(os.path.join(self.client.cache_folder, ".git")))
Ejemplo n.º 3
0
    def setUp(self):
        mocked_user_io = UserIO(out=TestBufferConanOutput())
        mocked_user_io.get_username = Mock(return_value="myuser")
        mocked_user_io.get_password = Mock(return_value="mypassword")

        requester = RequesterWithTokenMock()
        self.rest_client = RestApiClient(mocked_user_io.out,
                                         requester,
                                         revisions_enabled=False,
                                         put_headers=None)
        self.localdb = LocalDBMock()
        self.auth_manager = ConanApiAuthManager(self.rest_client,
                                                mocked_user_io, self.localdb)
        self.auth_manager.remote = Remote("myremote", "myurl", True, True)
        self.auth_manager.user = None
Ejemplo n.º 4
0
    def setUp(self):
        mocked_user_io = UserIO(out=TestBufferConanOutput())
        mocked_user_io.get_username = Mock(return_value="myuser")
        mocked_user_io.get_password = Mock(return_value="mypassword")

        requester = RequesterWithTokenMock()
        config = namedtuple("ConfigMock", "revisions_enabled download_cache")(False, None)
        self.rest_client_factory = RestApiClientFactory(mocked_user_io.out,
                                                        requester, config=config,
                                                        artifacts_properties=None)
        self.localdb = LocalDBMock()
        self.auth_manager = ConanApiAuthManager(self.rest_client_factory, mocked_user_io,
                                                self.localdb)
        self.remote = Remote("myremote", "myurl", True, True)
        self.ref = ConanFileReference.loads("lib/1.0@conan/stable")
Ejemplo n.º 5
0
 def _check(self, install_path):
     settings_path = self.client.cache.settings_path
     self.assertEqual(
         load(settings_path).splitlines(), settings_yml.splitlines())
     registry = self.client.cache.registry
     self.assertEqual(registry.remotes.list, [
         Remote("myrepo1", "https://myrepourl.net", False),
         Remote("my-repo-2", "https://myrepo2.com", True),
     ])
     self.assertEqual(registry.refs.list,
                      {"MyPkg/0.1@user/channel": "my-repo-2"})
     self.assertEqual(sorted(os.listdir(self.client.cache.profiles_path)),
                      sorted(["default", "linux", "windows"]))
     self.assertEqual(
         load(os.path.join(self.client.cache.profiles_path,
                           "linux")).splitlines(),
         linux_profile.splitlines())
     self.assertEqual(
         load(os.path.join(self.client.cache.profiles_path,
                           "windows")).splitlines(),
         win_profile.splitlines())
     conan_conf = ConanClientConfigParser(self.client.cache.conan_conf_path)
     self.assertEqual(conan_conf.get_item("log.run_to_output"), "False")
     self.assertEqual(conan_conf.get_item("log.run_to_file"), "False")
     self.assertEqual(conan_conf.get_item("log.level"), "10")
     self.assertEqual(conan_conf.get_item("general.compression_level"), "6")
     self.assertEqual(conan_conf.get_item("general.sysrequires_sudo"),
                      "True")
     self.assertEqual(conan_conf.get_item("general.cpu_count"), "1")
     self.assertEqual(conan_conf.get_item("general.config_install"),
                      install_path)
     self.assertEqual(conan_conf.get_item("proxies.no_proxy"),
                      "mylocalhost")
     self.assertEqual(conan_conf.get_item("proxies.https"), "None")
     self.assertEqual(conan_conf.get_item("proxies.http"),
                      "http://*****:*****@10.10.1.10:3128/")
     self.assertEqual(
         "#Custom pylint",
         load(os.path.join(self.client.cache.conan_folder, "pylintrc")))
     self.assertEqual(
         "",
         load(
             os.path.join(self.client.cache.conan_folder, "python",
                          "__init__.py")))
     self.assertEqual(
         "#hook dummy",
         load(os.path.join(self.client.cache.conan_folder, "hooks",
                           "dummy")))
     self.assertEqual(
         "#hook foo",
         load(
             os.path.join(self.client.cache.conan_folder, "hooks",
                          "foo.py")))
     self.assertEqual(
         "#hook custom",
         load(
             os.path.join(self.client.cache.conan_folder, "hooks", "custom",
                          "custom.py")))
     self.assertFalse(
         os.path.exists(
             os.path.join(self.client.cache.conan_folder, "hooks", ".git")))
     self.assertFalse(
         os.path.exists(os.path.join(self.client.cache.conan_folder,
                                     ".git")))