|
@@ -4,33 +4,31 @@ from flexmock import flexmock
|
|
|
from borgmatic.config import validate as module
|
|
|
|
|
|
|
|
|
-def test_format_error_path_element_formats_array_index():
|
|
|
- module.format_error_path_element(3) == '[3]'
|
|
|
+def test_format_json_error_path_element_formats_array_index():
|
|
|
+ module.format_json_error_path_element(3) == '[3]'
|
|
|
|
|
|
|
|
|
-def test_format_error_path_element_formats_property():
|
|
|
- module.format_error_path_element('foo') == '.foo'
|
|
|
+def test_format_json_error_path_element_formats_property():
|
|
|
+ module.format_json_error_path_element('foo') == '.foo'
|
|
|
|
|
|
|
|
|
-def test_format_error_formats_error_including_path():
|
|
|
- flexmock(module).format_error_path_element = lambda element: '.{}'.format(element)
|
|
|
+def test_format_json_error_formats_error_including_path():
|
|
|
+ flexmock(module).format_json_error_path_element = lambda element: '.{}'.format(element)
|
|
|
error = flexmock(message='oops', path=['foo', 'bar'])
|
|
|
|
|
|
- assert module.format_error(error) == "At 'foo.bar': oops"
|
|
|
+ assert module.format_json_error(error) == "At 'foo.bar': oops"
|
|
|
|
|
|
|
|
|
-def test_format_error_formats_error_without_path():
|
|
|
- flexmock(module).should_receive('format_error_path_element').never()
|
|
|
+def test_format_json_error_formats_error_without_path():
|
|
|
+ flexmock(module).should_receive('format_json_error_path_element').never()
|
|
|
error = flexmock(message='oops', path=[])
|
|
|
|
|
|
- assert module.format_error(error) == 'At the top level: oops'
|
|
|
+ assert module.format_json_error(error) == 'At the top level: oops'
|
|
|
|
|
|
|
|
|
-def test_validation_error_string_contains_error_messages_and_config_filename():
|
|
|
- flexmock(module).format_error = lambda error: error.message
|
|
|
- error = module.Validation_error(
|
|
|
- 'config.yaml', (flexmock(message='oops', path=None), flexmock(message='uh oh'))
|
|
|
- )
|
|
|
+def test_validation_error_string_contains_errors():
|
|
|
+ flexmock(module).format_json_error = lambda error: error.message
|
|
|
+ error = module.Validation_error('config.yaml', ('oops', 'uh oh'))
|
|
|
|
|
|
result = str(error)
|
|
|
|
|
@@ -40,7 +38,7 @@ def test_validation_error_string_contains_error_messages_and_config_filename():
|
|
|
|
|
|
|
|
|
def test_apply_logical_validation_raises_if_archive_name_format_present_without_prefix():
|
|
|
- flexmock(module).format_error = lambda error: error.message
|
|
|
+ flexmock(module).format_json_error = lambda error: error.message
|
|
|
|
|
|
with pytest.raises(module.Validation_error):
|
|
|
module.apply_logical_validation(
|
|
@@ -53,7 +51,7 @@ def test_apply_logical_validation_raises_if_archive_name_format_present_without_
|
|
|
|
|
|
|
|
|
def test_apply_logical_validation_raises_if_archive_name_format_present_without_retention_prefix():
|
|
|
- flexmock(module).format_error = lambda error: error.message
|
|
|
+ flexmock(module).format_json_error = lambda error: error.message
|
|
|
|
|
|
with pytest.raises(module.Validation_error):
|
|
|
module.apply_logical_validation(
|
|
@@ -67,7 +65,7 @@ def test_apply_logical_validation_raises_if_archive_name_format_present_without_
|
|
|
|
|
|
|
|
|
def test_apply_locical_validation_raises_if_unknown_repository_in_check_repositories():
|
|
|
- flexmock(module).format_error = lambda error: error.message
|
|
|
+ flexmock(module).format_json_error = lambda error: error.message
|
|
|
|
|
|
with pytest.raises(module.Validation_error):
|
|
|
module.apply_logical_validation(
|