test_arguments.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import pytest
  2. from borgmatic.config import arguments as module
  3. def test_convert_value_type_passes_through_non_string_value():
  4. assert module.convert_value_type([1, 2], 'array') == [1, 2]
  5. def test_convert_value_type_passes_through_string_option_type():
  6. assert module.convert_value_type('foo', 'string') == 'foo'
  7. def test_convert_value_type_parses_array_option_type():
  8. assert module.convert_value_type('[foo, bar]', 'array') == ['foo', 'bar']
  9. def test_convert_value_type_with_array_option_type_and_no_array_raises():
  10. with pytest.raises(ValueError):
  11. module.convert_value_type('{foo, bar}', 'array')
  12. def test_convert_value_type_parses_object_option_type():
  13. assert module.convert_value_type('{foo: bar}', 'object') == {'foo': 'bar'}
  14. def test_convert_value_type_with_invalid_value_raises():
  15. with pytest.raises(ValueError):
  16. module.convert_value_type('{foo, bar', 'object')
  17. def test_convert_value_type_with_unknown_option_type_raises():
  18. with pytest.raises(ValueError):
  19. module.convert_value_type('{foo, bar}', 'thingy')