-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathtest_error.py
42 lines (32 loc) · 1.53 KB
/
test_error.py
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
39
40
41
42
"""Unit tests for the error classes in the runpod.error module."""
import unittest
# Assuming the error classes are in a file named 'error.py'
from runpod.error import AuthenticationError, QueryError, RunPodError
class TestErrorClasses(unittest.TestCase):
"""Unit tests for the error classes in the runpod.error module."""
def test_run_pod_error_with_message(self):
"""Test the RunPodError class with a message."""
error_msg = "An error occurred"
err = RunPodError(error_msg)
self.assertEqual(str(err), error_msg)
def test_run_pod_error_without_message(self):
"""Test the RunPodError class without a message."""
err = RunPodError()
self.assertEqual(str(err), "None")
def test_authentication_error(self):
"""Test the AuthenticationError class."""
error_msg = "Authentication failed"
err = AuthenticationError(error_msg)
self.assertEqual(str(err), error_msg)
def test_query_error_with_message_and_query(self):
"""Test the QueryError class with a message and query."""
error_msg = "Query failed"
query_str = "SELECT * FROM some_table WHERE condition"
err = QueryError(error_msg, query_str)
self.assertEqual(str(err), error_msg)
self.assertEqual(err.query, query_str)
def test_query_error_without_message_and_query(self):
"""Test the QueryError class without a message or query."""
err = QueryError()
self.assertEqual(str(err), "None")
self.assertIsNone(err.query)