def main(): ap = argparse.ArgumentParser() ap.add_argument('-p', type=str, help='Config location path', default='./config') ap.add_argument('-f', type=str, help='Config file name (without .yml extension)', default='config') args = ap.parse_args() configuration.setup_logging() configuration.setup_config(args.p, args.f) try: configuration.validate_config() except ValidationError as e: log.error(".".join(x for x in e.path if isinstance(x, str)) + ": " + e.message) sys.exit(1) d = data.Data() d.schedule_data_download() dp = display.Display(d) dp.start()
def test_brightness_standard(default, increase_on_click, maximum, expected_error, error_matcher): settings = configuration.v.all_settings() settings['brightness']['standard']['default'] = default settings['brightness']['standard']['increase_on_click'] = increase_on_click settings['brightness']['standard']['max'] = maximum if expected_error: with pytest.raises(ValidationError, match=error_matcher): configuration.validate_config() else: configuration.validate_config()
def test_brightness_time_dependent_times(time, value, expected_error, error_matcher): settings = configuration.v.all_settings() settings['brightness']['mode'] = 'time_dependent' settings['brightness']['time_dependent']['times'].append({ 'from': time, 'value': value }) if expected_error: with pytest.raises(ValidationError, match=error_matcher): configuration.validate_config() else: configuration.validate_config()
def test_exchange_rate_wrong_currency_code(from_code, to_code, expected_error, error_matcher): configuration.v.all_settings()['modes']['exchange_rate']['types'].append({ 'from': from_code, 'to': to_code }) if expected_error: with pytest.raises(ValidationError, match=error_matcher): configuration.validate_config() else: configuration.validate_config()
def test_default_config_without_file(): configuration.validate_config()
def test_instagram_no_api_key(): configuration.v.all_settings()['modes']['instagram']['api_key'] = None with pytest.raises(ValidationError, match='None'): configuration.validate_config()
def test_weather_wrong_unit(): wrong_unit = 'X' configuration.v.all_settings()['modes']['weather']['unit'] = wrong_unit with pytest.raises(ValidationError, match=wrong_unit): configuration.validate_config()
def test_config_for_tests_validation(): configuration.validate_config()