Пример #1
0
 def test_fetch_config(self, cfg_url):
     c1 = config.fetch_config("zdravomil", cfg_url)
     c2 = config.fetch_config("dockerfile-linter", cfg_url)
     c3 = config.fetch_config("betka", cfg_url)
     c4 = config.fetch_config("upstream-to-downstream", cfg_url)
     assert c1 == c2
     # make sure the 'global' key has been merged into all bots` keys
     assert "notifications" in c1
     assert c3 == c4
     assert "notifications" in c3
Пример #2
0
 def get_bot_cfg_yaml(self, branch: str) -> Dict:
     """
     :return: bot-cfg.yml config
     """
     source_url = cfg_url(
         repo=f"{self.config_json['namespace_containers']}/{self.image}",
         branch=branch,
     )
     return fetch_config("upstream-to-downstream", source_url)
Пример #3
0
    def is_enabled(self, config_url=None, config_path=None):
        """
        Is bot enabled in config ?
        If config_url OR config_path is provided, fetch/load the config first
        """
        if config_url and config_path:
            raise AttributeError("Provide EITHER config_url OR config_path")

        if config_url:
            self.config = fetch_config(self.cfg_key, config_url)
        elif config_path:
            self.config = load_configuration(config_path).get(self.cfg_key, {})

        if not self.config:
            raise RuntimeError("config has not been loaded yet")

        return self.config.get("enabled", False)
Пример #4
0
 def test_fetch_config(self, cfg_url):
     c1 = config.fetch_config("zdravomil", cfg_url)
     c2 = config.fetch_config("dockerfile-linter", cfg_url)
     assert c1 == c2
     # make sure the 'global' key has been merged into all bots` keys
     assert "notifications" in c1