else:
with pytest.raises(ValueError):
smb.validation.check_path(value)
+
+
+def _ovr(value):
+ value[
+ smb.validation.CUSTOM_CAUTION_KEY
+ ] = smb.validation.CUSTOM_CAUTION_VALUE
+ return value
+
+
+@pytest.mark.parametrize(
+ "value,errmatch",
+ [
+ ({"foo": "bar"}, "lack"),
+ (_ovr({"foo": "bar"}), ""),
+ (_ovr({"foo": "bar", "zip": "zap"}), ""),
+ (_ovr({"mod:foo": "bar", "zip": "zap"}), ""),
+ (_ovr({"foo\n": "bar"}), "newlines"),
+ (_ovr({"foo": "bar\n"}), "newlines"),
+ (_ovr({"[foo]": "bar\n"}), "brackets"),
+ ],
+)
+def test_check_custom_options(value, errmatch):
+ if not errmatch:
+ smb.validation.check_custom_options(value)
+ else:
+ with pytest.raises(ValueError, match=errmatch):
+ smb.validation.check_custom_options(value)
+
+
+def test_clean_custom_options():
+ orig = {'foo': 'bar', 'big': 'bad', 'bugs': 'bongo'}
+ updated = _ovr(dict(orig))
+ smb.validation.check_custom_options(updated)
+ assert smb.validation.clean_custom_options(updated) == orig
+ assert smb.validation.clean_custom_options(None) is None