Added new exception [CI SKIP]

pull/27/head
Jef Roosens 2021-05-15 14:04:34 +02:00
parent 0dc1b3ded4
commit 8734cdf180
Signed by: Jef Roosens
GPG Key ID: 955C0660072F691F
2 changed files with 20 additions and 1 deletions

View File

@ -34,3 +34,22 @@ class MissingKeyError(Exception):
self.message = "Missing key(s): {}".format(", ".join(keys)) self.message = "Missing key(s): {}".format(", ".join(keys))
super().__init__() super().__init__()
class InvalidValueError(Exception):
"""Thrown when a key contains an invalid value."""
def __init__(self, key: str, expected: str, actual: str):
"""Create a new InvalidValueError given the arguments.
Args:
key: the key containing the invalid value
expected: name of the expected type
actual: name of the actual type
"""
self.message = (
f"Invalid value for key {key}: expected {expected}, "
f"got {actual}"
)
super().__init__()

View File

@ -1,5 +1,5 @@
"""Tests wether the skeleton merge works.""" """Tests wether the skeleton merge works."""
from app.skeleton import merge_with_skeleton, MissingKeyError, InvalidKeyError from app.skeleton import merge_with_skeleton
from app.exceptions import InvalidKeyError, MissingKeyError from app.exceptions import InvalidKeyError, MissingKeyError
import pytest import pytest