def test_cmd_env_def(self): """ Setup: --config on cmd, $hma_CONFIG is set, $HOME/.hma exists Result: load --config """ with ModifiedEnvironment(hma_CONFIG=self.env_filename, HOME=self.tmpd): cfg = config.getConfig(self.cmd_filename) ae = self.assertEqual ae(["hma"], cfg.sections()) ae(self.cmd_filename, cfg.get("hma", "omit-patterns")) ae(self.cmd_run_coverage, cfg.getboolean("hma", "run-coverage")) ae(self.cmd_logging, cfg.getboolean("hma", "logging")) ae(self.env_no_skip_report, cfg.getboolean("hma", "no-skip-report")) ae(self.default_version, cfg.getboolean("hma", "version"))
def test_nocmd_env_def(self): """ Setup: no --config option, $hma_CONFIG is set, $HOME/.hma exists Result: load $hma_CONFIG """ os.unlink(self.cmd_filename) with ModifiedEnvironment(hma_CONFIG=self.env_filename, HOME=self.tmpd): cfg = config.getConfig() ae = self.assertEqual ar = self.assertRaises ae(["hma"], cfg.sections()) ae(self.env_filename, cfg.get("hma", "omit-patterns")) ar(configparser.NoOptionError, cfg.get, "hma", "run-coverage") ae(self.env_logging, cfg.getboolean("hma", "logging")) ae(self.env_no_skip_report, cfg.getboolean("hma", "no-skip-report")) ae(self.default_version, cfg.getboolean("hma", "version"))
def test_cmd_noenv_nodef(self): """ Setup: --config on cmd, $hma_CONFIG unset, $HOME/.hma does not exist Result: load --config """ os.unlink(self.env_filename) os.unlink(self.default_filename) with ModifiedEnvironment(hma_CONFIG=None, HOME=self.tmpd): cfg = config.getConfig(self.cmd_filename) ae = self.assertEqual ar = self.assertRaises ae(["hma"], cfg.sections()) ae(self.cmd_filename, cfg.get("hma", "omit-patterns")) ae(self.cmd_run_coverage, cfg.getboolean("hma", "run-coverage")) ae(self.cmd_logging, cfg.getboolean("hma", "logging")) ar(configparser.NoOptionError, cfg.getboolean, "hma", "no-skip-report") ar(configparser.NoOptionError, cfg.getboolean, "hma", "version")
def test_nocmd_noenv_nodef(self): """ Setup: no --config option, $hma_CONFIG unset, no $HOME/.hma Result: empty config """ os.unlink(self.default_filename) os.unlink(self.env_filename) os.unlink(self.cmd_filename) with ModifiedEnvironment(hma_CONFIG=None, HOME=self.tmpd): cfg = config.getConfig() ae = self.assertEqual ar = self.assertRaises ae([], cfg.sections()) ar(configparser.NoSectionError, cfg.get, "hma", "omit-patterns") ar(configparser.NoSectionError, cfg.get, "hma", "run-coverage") ar(configparser.NoSectionError, cfg.get, "hma", "logging") ar(configparser.NoSectionError, cfg.get, "hma", "no-skip-report") ar(configparser.NoSectionError, cfg.get, "hma", "version")