@@ -10,37 +10,45 @@ class DummyHTTP:
1010 def __init__ (self , headers ):
1111 self ._headers = headers
1212 def request (self , method , url , ** kwargs ):
13- # Simulate minimal Response-like object
13+ # Simulate minimal Response-like object (subset of requests.Response API used by code)
1414 resp = types .SimpleNamespace ()
1515 resp .headers = self ._headers
1616 resp .status_code = 204
17+ resp .text = ""
1718 def raise_for_status ():
1819 return None
20+ def json_func ():
21+ return {}
1922 resp .raise_for_status = raise_for_status
23+ resp .json = json_func
2024 return resp
2125
2226class TestableOData (ODataClient ):
2327 def __init__ (self , headers ):
2428 super ().__init__ (DummyAuth (), "https://org.example" , None )
2529 # Monkey-patch http client
2630 self ._http = types .SimpleNamespace (request = lambda method , url , ** kwargs : DummyHTTP (headers ).request (method , url , ** kwargs ))
31+ # Bypass optionset label conversion to keep response sequence stable for tests
32+ def _convert_labels_to_ints (self , logical_name , record ): # pragma: no cover - test shim
33+ return record
2734
2835def test__create_single_uses_odata_entityid ():
2936 guid = "11111111-2222-3333-4444-555555555555"
3037 headers = {"OData-EntityId" : f"https://org.example/api/data/v9.2/accounts({ guid } )" }
3138 c = TestableOData (headers )
32- result = c ._create_single ("accounts" , {"name" : "x" })
39+ # Current signature requires logical name explicitly
40+ result = c ._create_single ("accounts" , "account" , {"name" : "x" })
3341 assert result == guid
3442
3543def test__create_single_fallback_location ():
3644 guid = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
3745 headers = {"Location" : f"https://org.example/api/data/v9.2/contacts({ guid } )" }
3846 c = TestableOData (headers )
39- result = c ._create_single ("contacts" , {"firstname" : "x" })
47+ result = c ._create_single ("contacts" , "contact" , {"firstname" : "x" })
4048 assert result == guid
4149
4250def test__create_single_missing_headers_raises ():
4351 c = TestableOData ({})
4452 import pytest
4553 with pytest .raises (RuntimeError ):
46- c ._create_single ("accounts" , {"name" : "x" })
54+ c ._create_single ("accounts" , "account" , {"name" : "x" })
0 commit comments