@@ -2685,4 +2685,40 @@ def test_custom_with_get_entities_and_chained_filters_url_params(service):
26852685 request = employees .filter (ID__range = (20 , 50 )).filter (NickName = "Tim" ).count ()
26862686
26872687 assert request .get_query_params () == {'foo' : 'bar' , '$fizz' : 'buzz' , '$filter' : "ID gte 20 and ID lte 50 and NickName eq 'Tim'" }
2688- assert request .get_path () == 'Employees/$count'
2688+ assert request .get_path () == 'Employees/$count'
2689+
2690+
2691+ @responses .activate
2692+ def test_custom_with_create_entity_url_params (service ):
2693+ """Test that `custom` after creating entity works correctly"""
2694+
2695+ # pylint: dispyable=redefined-outer-name
2696+
2697+ responses .add (
2698+ responses .POST ,
2699+ f"{ service .url } /MasterEntities?foo=bar" ,
2700+ headers = {
2701+ 'Content-type' : 'application/json' ,
2702+ 'ETag' : 'W/\" J0FtZXJpY2FuIEFpcmxpbmVzJw==\" '
2703+ },
2704+ json = {'d' : {
2705+ '__metadata' : {
2706+ 'etag' : 'W/\" J0FtZXJpY2FuIEFpcmxpbmVzJw==\" ' ,
2707+ },
2708+ 'Key' : '12345' ,
2709+ 'Data' : 'abcd'
2710+ }},
2711+ status = 201 )
2712+
2713+ oDataHttpRequest = service .entity_sets .MasterEntities .create_entity ().set (** {'Key' : '1234' , 'Data' : 'abcd' }).custom ("foo" , "bar" )
2714+
2715+ assert oDataHttpRequest .get_query_params () == {'foo' : 'bar' }
2716+ assert oDataHttpRequest .get_path () == 'MasterEntities'
2717+ assert oDataHttpRequest .get_method () == 'POST'
2718+ assert oDataHttpRequest .get_body () == '{"Key": "1234", "Data": "abcd"}'
2719+
2720+ result = oDataHttpRequest .execute ()
2721+
2722+ assert result .Key == '12345'
2723+ assert result .Data == 'abcd'
2724+ assert result .etag == 'W/\" J0FtZXJpY2FuIEFpcmxpbmVzJw==\" '
0 commit comments