def test_required_settings_types_should_not_raise_value_error_for_valid_types( self, settings_dict_required_types_valid_types): required_settings_types(settings_dict_required_types_valid_types) def converted_value(key): return settings_dict_required_types_valid_types[key] assert converted_value('STRING_NONE') is None assert converted_value('INTEGER_NONE') is None assert converted_value('FLOAT_NONE') is None assert converted_value('BOOL_NONE') is None assert isinstance(converted_value('STRING_NATIVE'), str) assert isinstance(converted_value('INTEGER_NATIVE'), int) assert isinstance(converted_value('INTEGER_PARSED'), int) assert isinstance(converted_value('FLOAT_NATIVE'), float) assert isinstance(converted_value('FLOAT_PARSED'), float) assert isinstance(converted_value('BOOL_NATIVE'), bool) assert isinstance(converted_value('BOOL_PARSED_1'), bool) assert isinstance(converted_value('BOOL_PARSED_3'), bool) assert isinstance(converted_value('BOOL_PARSED_4'), bool) assert isinstance(converted_value('BOOL_PARSED_5'), bool) assert isinstance(converted_value('JSON_LOADS_PARSED_1'), dict) assert isinstance(converted_value('JSON_LOADS_PARSED_2'), bool) assert isinstance(converted_value('JSON_LOADS_PARSED_3'), int) assert converted_value('JSON_LOADS_PARSED_1') == {'simple': 'value'} assert converted_value('JSON_LOADS_PARSED_2') is True assert converted_value('JSON_LOADS_PARSED_3') == 1 assert converted_value('JSON_LOADS_PARSED_4') == [1, 3] assert converted_value('JSON_LOADS_PARSED_5') == [1, 3] assert converted_value('JSON_LOADS_PARSED_6') == {'simple': 'value'}
def test_required_settings_types_should_raise_value_error_for_invalid_types( self, settings_dict_required_types_invalid_types): with pytest.raises(ValueError) as exc: required_settings_types(settings_dict_required_types_invalid_types) assert 'SIMPLE_INTEGER' in str(exc.value) assert 'SIMPLE_BOOL' in str(exc.value)
def test_required_settings_types_should_not_raise_value_error_for_valid_types( self, settings_dict_required_types_valid_types ): required_settings_types(settings_dict_required_types_valid_types) def converted_value(key): return settings_dict_required_types_valid_types[key] assert converted_value('STRING_NONE') is None assert converted_value('INTEGER_NONE') is None assert converted_value('FLOAT_NONE') is None assert converted_value('BOOL_NONE') is None assert isinstance(converted_value('STRING_NATIVE'), str) assert isinstance(converted_value('INTEGER_NATIVE'), int) assert isinstance(converted_value('INTEGER_PARSED'), int) assert isinstance(converted_value('FLOAT_NATIVE'), float) assert isinstance(converted_value('FLOAT_PARSED'), float) assert isinstance(converted_value('BOOL_NATIVE'), bool) assert isinstance(converted_value('BOOL_PARSED_1'), bool) assert isinstance(converted_value('BOOL_PARSED_3'), bool) assert isinstance(converted_value('BOOL_PARSED_4'), bool) assert isinstance(converted_value('BOOL_PARSED_5'), bool) assert isinstance(converted_value('JSON_LOADS_PARSED_1'), dict) assert isinstance(converted_value('JSON_LOADS_PARSED_2'), bool) assert isinstance(converted_value('JSON_LOADS_PARSED_3'), int) assert converted_value('JSON_LOADS_PARSED_1') == {'simple': 'value'} assert converted_value('JSON_LOADS_PARSED_2') == True assert converted_value('JSON_LOADS_PARSED_3') == 1
def test_required_settings_types_should_raise_value_error_for_an_unsupported_type( self, settings_dict_required_types_unsupported_type): with pytest.raises(ValueError) as exc: required_settings_types( settings_dict_required_types_unsupported_type) assert 'UNSUPPORTED_TYPE' in str(exc.value) assert 'SIMPLE_INTEGER' not in str(exc.value)
def test_required_settings_types_should_raise_value_error_for_invalid_types( self, settings_dict_required_types_invalid_types ): with pytest.raises(ValueError) as exc: required_settings_types(settings_dict_required_types_invalid_types) assert 'SIMPLE_INTEGER' in str(exc) assert 'SIMPLE_BOOL' in str(exc)
def test_required_settings_types_should_raise_value_error_for_an_unsupported_type( self, settings_dict_required_types_unsupported_type ): with pytest.raises(ValueError) as exc: required_settings_types( settings_dict_required_types_unsupported_type ) assert 'UNSUPPORTED_TYPE' in str(exc) assert 'SIMPLE_INTEGER' not in str(exc)