|
6 | 6 | ListTmSegmentsOrderBy, |
7 | 7 | ListTmsOrderBy, |
8 | 8 | TranslationMemoryPatchPath, |
| 9 | + TranslationMemorySegmentBatchOperation, |
| 10 | + TranslationMemorySegmentBatchOperationPath, |
9 | 11 | TranslationMemorySegmentRecordOperation, |
10 | 12 | TranslationMemorySegmentRecordOperationPath, |
11 | 13 | ) |
@@ -275,6 +277,54 @@ def test_edit_tm_segment( |
275 | 277 | ], |
276 | 278 | ) |
277 | 279 |
|
| 280 | + @mock.patch("crowdin_api.requester.APIRequester.request") |
| 281 | + def test_tm_segment_batch_operations(self, m_request, base_absolut_url): |
| 282 | + m_request.return_value = "response" |
| 283 | + |
| 284 | + data = [ |
| 285 | + { |
| 286 | + "op": TranslationMemorySegmentBatchOperation.ADD, |
| 287 | + "path": TranslationMemorySegmentBatchOperationPath.ADD, |
| 288 | + "value": { |
| 289 | + "records": [ |
| 290 | + { |
| 291 | + "languageId": "uk", |
| 292 | + "text": "Перекладений текст", |
| 293 | + } |
| 294 | + ] |
| 295 | + }, |
| 296 | + }, |
| 297 | + { |
| 298 | + "op": TranslationMemorySegmentBatchOperation.ADD, |
| 299 | + "path": TranslationMemorySegmentBatchOperationPath.ADD_RECORD, |
| 300 | + "value": { |
| 301 | + "languageId": "it", |
| 302 | + "text": "Ciao, mondo!", |
| 303 | + }, |
| 304 | + }, |
| 305 | + { |
| 306 | + "op": TranslationMemorySegmentBatchOperation.REMOVE, |
| 307 | + "path": TranslationMemorySegmentBatchOperationPath.REMOVE, |
| 308 | + }, |
| 309 | + { |
| 310 | + "op": TranslationMemorySegmentBatchOperation.REMOVE, |
| 311 | + "path": TranslationMemorySegmentBatchOperationPath.REMOVE_RECORD, |
| 312 | + }, |
| 313 | + { |
| 314 | + "op": TranslationMemorySegmentBatchOperation.REPLACE, |
| 315 | + "path": TranslationMemorySegmentBatchOperationPath.REPLACE, |
| 316 | + "value": "Testo tradotto", |
| 317 | + }, |
| 318 | + ] |
| 319 | + |
| 320 | + resource = self.get_resource(base_absolut_url) |
| 321 | + assert resource.tm_segment_batch_operations(tmId=1, data=data) == "response" |
| 322 | + m_request.assert_called_once_with( |
| 323 | + method="patch", |
| 324 | + path=resource.get_tm_segments_path(tmId=1), |
| 325 | + request_data=data, |
| 326 | + ) |
| 327 | + |
278 | 328 | # Export |
279 | 329 | @pytest.mark.parametrize( |
280 | 330 | "in_params, path", |
|
0 commit comments