|
@@ -1,3 +1,7 @@
|
|
|
|
+import os
|
|
|
|
+import sys
|
|
|
|
+from io import StringIO
|
|
|
|
+
|
|
import pytest
|
|
import pytest
|
|
from flexmock import flexmock
|
|
from flexmock import flexmock
|
|
|
|
|
|
@@ -5,7 +9,23 @@ from borgmatic.config import validate as module
|
|
|
|
|
|
|
|
|
|
def test_schema_filename_finds_schema_path():
|
|
def test_schema_filename_finds_schema_path():
|
|
- module.schema_filename().endswith('/borgmatic/config/schema.yaml')
|
|
|
|
|
|
+ schema_path = '/var/borgmatic/config/schema.yaml'
|
|
|
|
+
|
|
|
|
+ flexmock(os.path).should_receive('dirname').and_return("/var/borgmatic/config")
|
|
|
|
+ builtins = flexmock(sys.modules['builtins'])
|
|
|
|
+ builtins.should_receive('open').with_args(schema_path).and_return(StringIO())
|
|
|
|
+ assert module.schema_filename() == schema_path
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def test_schema_filename_raises_filenotfounderror():
|
|
|
|
+ schema_path = '/var/borgmatic/config/schema.yaml'
|
|
|
|
+
|
|
|
|
+ flexmock(os.path).should_receive('dirname').and_return("/var/borgmatic/config")
|
|
|
|
+ builtins = flexmock(sys.modules['builtins'])
|
|
|
|
+ builtins.should_receive('open').with_args(schema_path).and_raise(FileNotFoundError)
|
|
|
|
+
|
|
|
|
+ with pytest.raises(FileNotFoundError):
|
|
|
|
+ module.schema_filename()
|
|
|
|
|
|
|
|
|
|
def test_format_json_error_path_element_formats_array_index():
|
|
def test_format_json_error_path_element_formats_array_index():
|