1
- import pickle
2
-
3
1
from ragbits .document_search .documents .exceptions import (
4
2
SourceConnectionError ,
5
3
SourceError ,
@@ -14,50 +12,19 @@ def test_source_error_init():
14
12
assert str (error ) == "Test error message"
15
13
16
14
17
- def test_source_error_pickle ():
18
- original = SourceError ("Test pickle message" )
19
- pickled = pickle .dumps (original )
20
- unpickled = pickle .loads (pickled ) # noqa: S301
21
-
22
- assert isinstance (unpickled , SourceError )
23
- assert unpickled .message == "Test pickle message"
24
- assert str (unpickled ) == "Test pickle message"
25
-
26
-
27
15
def test_source_connection_error_init ():
28
16
error = SourceConnectionError ()
29
17
assert error .message == "Connection error."
30
18
assert str (error ) == "Connection error."
31
19
32
20
33
- def test_source_connection_error_pickle ():
34
- original = SourceConnectionError ()
35
- pickled = pickle .dumps (original )
36
- unpickled = pickle .loads (pickled ) # noqa: S301
37
-
38
- assert isinstance (unpickled , SourceConnectionError )
39
- assert unpickled .message == "Connection error."
40
- assert str (unpickled ) == "Connection error."
41
-
42
-
43
21
def test_source_not_found_error_init ():
44
22
error = SourceNotFoundError ("test-source-id" )
45
23
assert error .source_id == "test-source-id"
46
24
assert error .message == "Source with ID test-source-id not found."
47
25
assert str (error ) == "Source with ID test-source-id not found."
48
26
49
27
50
- def test_source_not_found_error_pickle ():
51
- original = SourceNotFoundError ("test-source-id" )
52
- pickled = pickle .dumps (original )
53
- unpickled = pickle .loads (pickled ) # noqa: S301
54
-
55
- assert isinstance (unpickled , SourceNotFoundError )
56
- assert unpickled .source_id == "test-source-id"
57
- assert unpickled .message == "Source with ID test-source-id not found."
58
- assert str (unpickled ) == "Source with ID test-source-id not found."
59
-
60
-
61
28
def test_web_download_error_init ():
62
29
url = "https://example.com/file.pdf"
63
30
code = 404
@@ -67,17 +34,3 @@ def test_web_download_error_init():
67
34
assert error .code == code
68
35
assert error .message == f"Download of { url } failed with code { code } ."
69
36
assert str (error ) == f"Download of { url } failed with code { code } ."
70
-
71
-
72
- def test_web_download_error_pickle ():
73
- url = "https://example.com/file.pdf"
74
- code = 404
75
- original = WebDownloadError (url , code )
76
- pickled = pickle .dumps (original )
77
- unpickled = pickle .loads (pickled ) # noqa: S301
78
-
79
- assert isinstance (unpickled , WebDownloadError )
80
- assert unpickled .url == url
81
- assert unpickled .code == code
82
- assert unpickled .message == f"Download of { url } failed with code { code } ."
83
- assert str (unpickled ) == f"Download of { url } failed with code { code } ."
0 commit comments