MCPcopy Create free account
hub / github.com/datastax/astrapy / test_dataapihttpexception

Function test_dataapihttpexception

tests/base/unit/test_exceptions.py:49–95  ·  view source on GitHub ↗

Test that regardless of how incorrect the input httpx error, nothing breaks.

()

Source from the content-addressed store, hash-verified

47
48@pytest.mark.describe("test DataAPIHttpException")
49def test_dataapihttpexception() -> None:
50 """Test that regardless of how incorrect the input httpx error, nothing breaks."""
51 se0 = HTTPStatusError(message="httpx_message", request="req", response=None) # type: ignore[arg-type]
52 se1 = HTTPStatusError(message="httpx_message", request="req", response="blah") # type: ignore[arg-type]
53 se2 = HTTPStatusError(
54 message="httpx_message",
55 request="req", # type: ignore[arg-type]
56 response=Response(status_code=500, text="blah"),
57 )
58 se3 = HTTPStatusError(
59 message="httpx_message",
60 request="req", # type: ignore[arg-type]
61 response=Response(status_code=500, text='{"blabla": 1}'),
62 )
63 se4 = HTTPStatusError(
64 message="httpx_message",
65 request="req", # type: ignore[arg-type]
66 response=Response(status_code=500, text='{"errors": []}'),
67 )
68 se5 = HTTPStatusError(
69 message="httpx_message",
70 request="req", # type: ignore[arg-type]
71 response=Response(
72 status_code=500,
73 text=FULL_RESPONSE_OF_500,
74 ),
75 )
76
77 de0 = DataAPIHttpException.from_httpx_error(se0)
78 de1 = DataAPIHttpException.from_httpx_error(se1)
79 de2 = DataAPIHttpException.from_httpx_error(se2)
80 de3 = DataAPIHttpException.from_httpx_error(se3)
81 de4 = DataAPIHttpException.from_httpx_error(se4)
82 de5 = DataAPIHttpException.from_httpx_error(se5)
83
84 repr(de0)
85 repr(de1)
86 repr(de2)
87 repr(de3)
88 repr(de4)
89 repr(de5)
90 str(de0)
91 str(de1)
92 str(de2)
93 str(de3)
94 str(de4)
95 assert ERROR_MESSAGE in str(de5)
96
97
98@pytest.mark.describe("test DataAPIHttpException raising 500 from a mock server, sync")

Callers

nothing calls this directly

Calls 1

from_httpx_errorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…