Exemple #1
0
def mock_mc(tmpdir):
    """
    Mock a Mozilla Central repository
    """
    config = {
        "name": "mozilla-central",
        "ssh_user": "******",
        "ssh_key": "privateSSHkey",
        "url": "http://mozilla-central",
        "try_url": "http://mozilla-central/try",
        "batch_size": 100,
    }
    repo = Repository(config, tmpdir.realpath())
    repo.repo = build_repository(tmpdir, "mozilla-central")
    repo.clone = MagicMock(side_effect=asyncio.coroutine(lambda: True))
    return repo
Exemple #2
0
def mock_nss(tmpdir):
    """
    Mock an NSS repository
    """
    config = {
        "name": "nss",
        "ssh_user": "******",
        "ssh_key": "privateSSHkey",
        "url": "http://nss",
        "try_url": "http://nss/try",
        "try_mode": "syntax",
        "try_syntax": "-a -b XXX -c YYY",
        "batch_size": 100,
    }
    repo = Repository(config, tmpdir.realpath())
    repo.repo = build_repository(tmpdir, "nss")
    repo.clone = MagicMock(side_effect=asyncio.coroutine(lambda: True))
    return repo
Exemple #3
0
 def get_repositories(self, repositories, cache_root):
     """
     Configure repositories, and index them by phid
     """
     repositories = {
         phab_repo["phid"]: Repository(conf, cache_root)
         for phab_repo in self.api.list_repositories()
         for conf in repositories
         if phab_repo["fields"]["name"] == conf["name"]
     }
     assert len(repositories) > 0, "No repositories configured"
     logger.info("Configured repositories",
                 names=[r.name for r in repositories.values()])
     return repositories
Exemple #4
0
    def get_repositories(self, repositories, cache_root, default_ssh_key=None):
        """
        Configure repositories, and index them by phid
        """
        def _build_conf(config):
            # Use the default ssh key when specific repo key is not available
            if config.get("ssh_key") is None:
                config["ssh_key"] = default_ssh_key
            assert config["ssh_key"] is not None, "Missing ssh key"
            return config

        repositories = {
            phab_repo["phid"]: Repository(_build_conf(conf), cache_root)
            for phab_repo in self.api.list_repositories()
            for conf in repositories
            if phab_repo["fields"]["name"] == conf["name"]
        }
        assert len(repositories) > 0, "No repositories configured"
        logger.info("Configured repositories",
                    names=[r.name for r in repositories.values()])
        return repositories