Make path validation raise ValidationError instead of ValueError

This commit is contained in:
2022-05-05 08:33:03 +02:00
parent 00eb91e4cd
commit 476e6ad22d
2 changed files with 11 additions and 9 deletions

View File

@@ -3,6 +3,7 @@
import pytest
from earthsnake.exc import ValidationError
from earthsnake.identity import Identity
from earthsnake.path import Path
@@ -22,7 +23,7 @@ from earthsnake.path import Path
def test_invalid(path: str, error_msg: str) -> None:
"""Test if validation fails for invalid paths"""
with pytest.raises(ValueError) as ctx:
with pytest.raises(ValidationError) as ctx:
Path.validate(path)
assert error_msg in str(ctx.value)
@@ -31,7 +32,7 @@ def test_invalid(path: str, error_msg: str) -> None:
def test_invalid_non_ephemeral() -> None:
"""Test validating ephemeral paths when ephemeral is not allowed"""
with pytest.raises(ValueError) as ctx:
with pytest.raises(ValidationError) as ctx:
Path.validate('/ephemeral!')
assert 'Only ephemeral paths may contain !' in str(ctx.value)