示例#1
0
def test_parse_config():
    config_file = os.path.join(os.getcwd(), 'tests', config_file_name)
    cp = WeathervaneConfigParser()
    cp.read(config_file)
    observed = cp.parse_config()
    expected_keys = [
        'extended-error-mode', 'channel', 'frequency', 'library', 'interval',
        'source', 'stations', 'bits', 'sleep-time', 'test', 'barometric_trend',
        'display'
    ]
    assert set(observed.keys()) == set(expected_keys)
    assert len(observed['bits']) == 16
    def test_recursion(self):
        p_end1, p_end2 = Pipe()
        cp = WeathervaneConfigParser()
        config_file = os.path.join(os.getcwd(), 'tests', 'config-test1.ini')
        cp.read(config_file)
        c = cp.parse_config()
        p = Process(target=fetch_weather_data, args=[p_end1, '6308'], kwargs=c)
        p.start()
        while not p_end2.poll():
            time.sleep(0.1)

        p_end2.recv()
示例#3
0
def test_rain_config():
    'Tests if rain configuration is correctly picked up. E.g. bit_13=rainFallLastHour,10,0,99.9,0.1'
    config_file = os.path.join(os.getcwd(), 'tests', config_file_name)
    cp = WeathervaneConfigParser()
    cp.read(config_file)
    observed = cp.parse_config()
    rain_config = observed['bits'][13]
    assert rain_config == {
        'key': 'rainFallLastHour',
        'length': '10',
        'min': '0',
        'max': '99.9',
        'step': '0.1'
    }
示例#4
0
def test_parse_station_numbers():
    config_file = os.path.join(os.getcwd(), 'tests', config_file_name)
    cp = WeathervaneConfigParser()
    cp.read(config_file)
    stations = cp.parse_station_numbers()
    assert stations == [6320, 6308]
示例#5
0
def get_configuration(args):
    config_parser = WeathervaneConfigParser()
    config_file = args.config
    config_parser.read(config_file)
    config = config_parser.parse_config()
    return config