File size: 1,044 Bytes
069f0a0
 
7d28de6
 
 
 
069f0a0
 
5d12635
069f0a0
 
 
 
 
 
 
 
 
5d12635
 
069f0a0
 
 
 
5d12635
 
069f0a0
5d12635
 
069f0a0
 
5d12635
069f0a0
 
5d12635
069f0a0
5d12635
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Unit tests for custom exceptions."""

import pytest

pytestmark = pytest.mark.unit

from src.utils.exceptions import (
    ConfigurationError,
    DeepBonerError,
    JudgeError,
    RateLimitError,
    SearchError,
)


class TestExceptions:
    """Tests for exception hierarchy."""

    def test_search_error_is_deepboner_error(self):
        assert issubclass(SearchError, DeepBonerError)

    def test_rate_limit_error_is_search_error(self):
        assert issubclass(RateLimitError, SearchError)

    def test_judge_error_is_deepboner_error(self):
        assert issubclass(JudgeError, DeepBonerError)

    def test_configuration_error_is_deepboner_error(self):
        assert issubclass(ConfigurationError, DeepBonerError)

    def test_subclass_caught_as_base(self):
        """Verify subclasses can be caught via DeepBonerError."""
        try:
            raise RateLimitError("rate limited")
        except DeepBonerError as exc:
            assert isinstance(exc, RateLimitError)
            assert isinstance(exc, DeepBonerError)