File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 UnauthorisedAccessError ,
1919 UnknownPlanError ,
2020 _create_task_exceptions ,
21+ _exception ,
2122)
2223from blueapi .config import OIDCConfig
2324from blueapi .service .authentication import SessionCacheManager , SessionManager
@@ -120,6 +121,21 @@ def test_create_task_exceptions(
120121 assert err .args [1 ] == content
121122
122123
124+ def test_exception_non_json_body_falls_back_to_text ():
125+ import json
126+
127+ response = Mock (spec = requests .Response )
128+ response .status_code = 500
129+ response .text = "Internal Server Error"
130+ response .json .side_effect = json .JSONDecodeError ("Expecting value" , "" , 0 )
131+ response .request = Mock ()
132+ response .request .url = "http://localhost:8000/test"
133+ response .content = b"Internal Server Error"
134+ err = _exception (response )
135+ assert isinstance (err , BlueskyRemoteControlError )
136+ assert err .args [1 ] == "Internal Server Error"
137+
138+
123139def test_auth_request_functionality (
124140 rest_with_auth : BlueapiRestClient ,
125141 mock_authn_server : responses .RequestsMock ,
You can’t perform that action at this time.
0 commit comments