def test_config_error(monkeypatch): monkeypatch.setattr('hisser.config.defaults.BAR', '', raising=False) monkeypatch.setattr('hisser.config.defaults.BOO', '', raising=False) opts = {'BAR': 'boo', 'BOO': ''} cfg = get_config(opts) with pytest.raises(Config.Error): cfg.int('BAR') with pytest.raises(Config.Error): cfg.str('BOO')
def test_simple(tmpdir): cfg = config.get_config({'DATA_DIR': str(tmpdir)}) cfg.ensure_dirs() server = cfg.server server.buf.set_ts(1000) for ts in range(1000, 1700, 60): data = 'm1 {0} 10\nm2 {0} 10\n'.format(ts).encode() server.process(data[:15]) server.process(data[15:], True) server.check_buffer(ts)
def get_config(data_dir, **opts): opts['DATA_DIR'] = data_dir opts['CARBON_BIND'] = '127.0.0.1:14000' opts['CARBON_BIND_UDP'] = '127.0.0.1:14001' opts['LINK_BIND'] = '127.0.0.1:14002' return config.get_config(opts)
def test_config_from_env(monkeypatch): monkeypatch.setattr('hisser.config.defaults.FOO', '', raising=False) opts = {'FOO': 20} os.environ['HISSER_FOO'] = '10' cfg = get_config(opts) assert cfg.FOO == '10'
def test_config_from_file(tmpdir, monkeypatch): monkeypatch.setattr('hisser.config.defaults.BOO', '', raising=False) tmpdir.join('boo').write('BOO = 10') cfg = get_config({}, str(tmpdir.join('boo'))) assert cfg.BOO == 10