@@ -193,6 +193,41 @@ def test_create_issue(self):
193
193
{"op" : "add" , "path" : "/fields/System.History" , "value" : "<p>Fix this.</p>\n " },
194
194
]
195
195
196
+ @responses .activate
197
+ def test_create_issue_title_too_long (self ):
198
+ responses .add (
199
+ responses .PATCH ,
200
+ "https://fabrikam-fiber-inc.visualstudio.com/0987654321/_apis/wit/workitems/$Microsoft.VSTS.WorkItemTypes.Task" ,
201
+ body = WORK_ITEM_RESPONSE ,
202
+ content_type = "application/json" ,
203
+ )
204
+
205
+ long_title = "A" * 200 # Title longer than VSTS's 128 character limit
206
+ expected_title = "A" * 125 + "..."
207
+
208
+ form_data = {
209
+ "title" : long_title ,
210
+ "description" : "Fix this." ,
211
+ "project" : "0987654321" ,
212
+ "work_item_type" : "Microsoft.VSTS.WorkItemTypes.Task" ,
213
+ }
214
+ assert self .integration .create_issue (form_data ) == {
215
+ "key" : self .issue_id ,
216
+ "description" : "Fix this." ,
217
+ "title" : expected_title ,
218
+ "metadata" : {"display_name" : "Fabrikam-Fiber-Git#309" },
219
+ }
220
+ request = responses .calls [- 1 ].request
221
+ assert request .headers ["Content-Type" ] == "application/json-patch+json"
222
+ payload = orjson .loads (request .body )
223
+ assert payload == [
224
+ {"op" : "add" , "path" : "/fields/System.Title" , "value" : expected_title },
225
+ # Adds both a comment and a description.
226
+ # See method for details.
227
+ {"op" : "add" , "path" : "/fields/System.Description" , "value" : "<p>Fix this.</p>\n " },
228
+ {"op" : "add" , "path" : "/fields/System.History" , "value" : "<p>Fix this.</p>\n " },
229
+ ]
230
+
196
231
@responses .activate
197
232
def test_create_issue_failure (self ):
198
233
form_data = {
0 commit comments