|
24 | 24 | from data import get_bom_with_component_setuptools_basic, get_bom_with_component_setuptools_with_cpe, \
|
25 | 25 | get_bom_with_component_toml_1, get_bom_with_component_setuptools_no_component_version, \
|
26 | 26 | get_bom_with_component_setuptools_with_release_notes, get_bom_with_component_setuptools_with_vulnerability, \
|
27 |
| - MOCK_UUID_1, MOCK_UUID_2, MOCK_UUID_3, MOCK_UUID_4, MOCK_UUID_5, MOCK_UUID_6, get_bom_just_complete_metadata, \ |
| 27 | + MOCK_UUID_1, MOCK_UUID_4, MOCK_UUID_5, MOCK_UUID_6, TEST_UUIDS, get_bom_just_complete_metadata, \ |
28 | 28 | get_bom_with_nested_services, get_bom_with_services_simple, get_bom_with_services_complex, \
|
29 | 29 | get_bom_with_component_setuptools_complete, get_bom_with_external_references
|
30 | 30 | from tests.base import BaseXmlTestCase
|
31 | 31 |
|
32 |
| -TEST_UUIDS = [ |
33 |
| - MOCK_UUID_1, MOCK_UUID_2, MOCK_UUID_3, MOCK_UUID_4, MOCK_UUID_5, MOCK_UUID_6 |
34 |
| -] |
35 |
| - |
36 | 32 |
|
37 | 33 | class TestOutputXml(BaseXmlTestCase):
|
38 | 34 |
|
@@ -258,165 +254,141 @@ def test_bom_v1_0_component_with_vulnerability(self) -> None:
|
258 | 254 | fixture='bom_setuptools.xml'
|
259 | 255 | )
|
260 | 256 |
|
261 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_6) |
| 257 | + @patch('cyclonedx.model.bom_ref.uuid4', return_value=MOCK_UUID_6) |
262 | 258 | def test_bom_v1_4_with_metadata_component(self, mock_uuid: Mock) -> None:
|
263 | 259 | self._validate_xml_bom(
|
264 | 260 | bom=get_bom_just_complete_metadata(), schema_version=SchemaVersion.V1_4,
|
265 | 261 | fixture='bom_with_full_metadata.xml'
|
266 | 262 | )
|
267 | 263 | mock_uuid.assert_called()
|
268 | 264 |
|
269 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_5) |
| 265 | + @patch('cyclonedx.model.bom_ref.uuid4', return_value=MOCK_UUID_5) |
270 | 266 | def test_bom_v1_3_with_metadata_component(self, mock_uuid: Mock) -> None:
|
271 | 267 | self._validate_xml_bom(
|
272 | 268 | bom=get_bom_just_complete_metadata(), schema_version=SchemaVersion.V1_3,
|
273 | 269 | fixture='bom_with_full_metadata.xml'
|
274 | 270 | )
|
275 | 271 | mock_uuid.assert_called()
|
276 | 272 |
|
277 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_4) |
| 273 | + @patch('cyclonedx.model.bom_ref.uuid4', return_value=MOCK_UUID_4) |
278 | 274 | def test_bom_v1_2_with_metadata_component(self, mock_uuid: Mock) -> None:
|
279 | 275 | self._validate_xml_bom(
|
280 | 276 | bom=get_bom_just_complete_metadata(), schema_version=SchemaVersion.V1_2,
|
281 | 277 | fixture='bom_with_full_metadata.xml'
|
282 | 278 | )
|
283 | 279 | mock_uuid.assert_called()
|
284 | 280 |
|
285 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_1) |
| 281 | + @patch('cyclonedx.model.bom_ref.uuid4', return_value=MOCK_UUID_1) |
286 | 282 | def test_bom_v1_1_with_metadata_component(self, mock_uuid: Mock) -> None:
|
287 | 283 | self._validate_xml_bom(
|
288 | 284 | bom=get_bom_just_complete_metadata(), schema_version=SchemaVersion.V1_1,
|
289 | 285 | fixture='bom_empty.xml'
|
290 | 286 | )
|
291 | 287 | mock_uuid.assert_called()
|
292 | 288 |
|
293 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_1) |
| 289 | + @patch('cyclonedx.model.bom_ref.uuid4', return_value=MOCK_UUID_1) |
294 | 290 | def test_bom_v1_0_with_metadata_component(self, mock_uuid: Mock) -> None:
|
295 | 291 | self._validate_xml_bom(
|
296 | 292 | bom=get_bom_just_complete_metadata(), schema_version=SchemaVersion.V1_0,
|
297 | 293 | fixture='bom_empty.xml'
|
298 | 294 | )
|
299 | 295 | mock_uuid.assert_called()
|
300 | 296 |
|
301 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_6) |
302 |
| - @patch('cyclonedx.model.service.uuid4', side_effect=TEST_UUIDS) |
303 |
| - def test_bom_v1_4_services_simple(self, mock_uuid_c: Mock, mock_uuid_s: Mock) -> None: |
| 297 | + @patch('cyclonedx.model.bom_ref.uuid4', side_effect=TEST_UUIDS) |
| 298 | + def test_bom_v1_4_services_simple(self, mock_uuid: Mock) -> None: |
304 | 299 | self._validate_xml_bom(
|
305 | 300 | bom=get_bom_with_services_simple(), schema_version=SchemaVersion.V1_4,
|
306 | 301 | fixture='bom_services_simple.xml'
|
307 | 302 | )
|
308 |
| - mock_uuid_c.assert_called() |
309 |
| - mock_uuid_s.assert_called() |
| 303 | + mock_uuid.assert_called() |
310 | 304 |
|
311 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_5) |
312 |
| - @patch('cyclonedx.model.service.uuid4', side_effect=TEST_UUIDS) |
313 |
| - def test_bom_v1_3_services_simple(self, mock_uuid_c: Mock, mock_uuid_s: Mock) -> None: |
| 305 | + @patch('cyclonedx.model.bom_ref.uuid4', side_effect=TEST_UUIDS) |
| 306 | + def test_bom_v1_3_services_simple(self, mock_uuid: Mock) -> None: |
314 | 307 | self._validate_xml_bom(
|
315 | 308 | bom=get_bom_with_services_simple(), schema_version=SchemaVersion.V1_3,
|
316 | 309 | fixture='bom_services_simple.xml'
|
317 | 310 | )
|
318 |
| - mock_uuid_c.assert_called() |
319 |
| - mock_uuid_s.assert_called() |
| 311 | + mock_uuid.assert_called() |
320 | 312 |
|
321 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_4) |
322 |
| - @patch('cyclonedx.model.service.uuid4', side_effect=TEST_UUIDS) |
323 |
| - def test_bom_v1_2_services_simple(self, mock_uuid_c: Mock, mock_uuid_s: Mock) -> None: |
| 313 | + @patch('cyclonedx.model.bom_ref.uuid4', side_effect=TEST_UUIDS) |
| 314 | + def test_bom_v1_2_services_simple(self, mock_uuid: Mock) -> None: |
324 | 315 | self._validate_xml_bom(
|
325 | 316 | bom=get_bom_with_services_simple(), schema_version=SchemaVersion.V1_2,
|
326 | 317 | fixture='bom_services_simple.xml'
|
327 | 318 | )
|
328 |
| - mock_uuid_c.assert_called() |
329 |
| - mock_uuid_s.assert_called() |
| 319 | + mock_uuid.assert_called() |
330 | 320 |
|
331 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_1) |
332 |
| - @patch('cyclonedx.model.service.uuid4', side_effect=TEST_UUIDS) |
333 |
| - def test_bom_v1_1_services_simple(self, mock_uuid_c: Mock, mock_uuid_s: Mock) -> None: |
| 321 | + @patch('cyclonedx.model.bom_ref.uuid4', side_effect=TEST_UUIDS) |
| 322 | + def test_bom_v1_1_services_simple(self, mock_uuid: Mock) -> None: |
334 | 323 | self._validate_xml_bom(
|
335 | 324 | bom=get_bom_with_services_simple(), schema_version=SchemaVersion.V1_1,
|
336 | 325 | fixture='bom_empty.xml'
|
337 | 326 | )
|
338 |
| - mock_uuid_c.assert_called() |
339 |
| - mock_uuid_s.assert_called() |
| 327 | + mock_uuid.assert_called() |
340 | 328 |
|
341 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_1) |
342 |
| - @patch('cyclonedx.model.service.uuid4', side_effect=TEST_UUIDS) |
343 |
| - def test_bom_v1_0_services_simple(self, mock_uuid_c: Mock, mock_uuid_s: Mock) -> None: |
| 329 | + @patch('cyclonedx.model.bom_ref.uuid4', side_effect=TEST_UUIDS) |
| 330 | + def test_bom_v1_0_services_simple(self, mock_uuid: Mock) -> None: |
344 | 331 | self._validate_xml_bom(
|
345 | 332 | bom=get_bom_with_services_simple(), schema_version=SchemaVersion.V1_0,
|
346 | 333 | fixture='bom_empty.xml'
|
347 | 334 | )
|
348 |
| - mock_uuid_c.assert_called() |
349 |
| - mock_uuid_s.assert_called() |
| 335 | + mock_uuid.assert_called() |
350 | 336 |
|
351 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_6) |
352 |
| - @patch('cyclonedx.model.service.uuid4', side_effect=TEST_UUIDS) |
353 |
| - def test_bom_v1_4_services_complex(self, mock_uuid_c: Mock, mock_uuid_s: Mock) -> None: |
| 337 | + @patch('cyclonedx.model.bom_ref.uuid4', side_effect=TEST_UUIDS) |
| 338 | + def test_bom_v1_4_services_complex(self, mock_uuid4: Mock) -> None: |
354 | 339 | self._validate_xml_bom(
|
355 | 340 | bom=get_bom_with_services_complex(), schema_version=SchemaVersion.V1_4,
|
356 | 341 | fixture='bom_services_complex.xml'
|
357 | 342 | )
|
358 |
| - mock_uuid_c.assert_called() |
359 |
| - mock_uuid_s.assert_called() |
| 343 | + mock_uuid4.assert_called() |
360 | 344 |
|
361 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_5) |
362 |
| - @patch('cyclonedx.model.service.uuid4', side_effect=TEST_UUIDS) |
363 |
| - def test_bom_v1_3_services_complex(self, mock_uuid_c: Mock, mock_uuid_s: Mock) -> None: |
| 345 | + @patch('cyclonedx.model.bom_ref.uuid4', side_effect=TEST_UUIDS) |
| 346 | + def test_bom_v1_3_services_complex(self, mock_uuid: Mock) -> None: |
364 | 347 | self._validate_xml_bom(
|
365 | 348 | bom=get_bom_with_services_complex(), schema_version=SchemaVersion.V1_3,
|
366 | 349 | fixture='bom_services_complex.xml'
|
367 | 350 | )
|
368 |
| - mock_uuid_c.assert_called() |
369 |
| - mock_uuid_s.assert_called() |
| 351 | + mock_uuid.assert_called() |
370 | 352 |
|
371 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_4) |
372 |
| - @patch('cyclonedx.model.service.uuid4', side_effect=TEST_UUIDS) |
373 |
| - def test_bom_v1_2_services_complex(self, mock_uuid_c: Mock, mock_uuid_s: Mock) -> None: |
| 353 | + @patch('cyclonedx.model.bom_ref.uuid4', side_effect=TEST_UUIDS) |
| 354 | + def test_bom_v1_2_services_complex(self, mock_uuid: Mock) -> None: |
374 | 355 | self._validate_xml_bom(
|
375 | 356 | bom=get_bom_with_services_complex(), schema_version=SchemaVersion.V1_2,
|
376 | 357 | fixture='bom_services_complex.xml'
|
377 | 358 | )
|
378 |
| - mock_uuid_c.assert_called() |
379 |
| - mock_uuid_s.assert_called() |
| 359 | + mock_uuid.assert_called() |
380 | 360 |
|
381 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_3) |
382 |
| - @patch('cyclonedx.model.service.uuid4', side_effect=TEST_UUIDS) |
383 |
| - def test_bom_v1_1_services_complex(self, mock_uuid_c: Mock, mock_uuid_s: Mock) -> None: |
| 361 | + @patch('cyclonedx.model.bom_ref.uuid4', side_effect=TEST_UUIDS) |
| 362 | + def test_bom_v1_1_services_complex(self, mock_uuid: Mock) -> None: |
384 | 363 | self._validate_xml_bom(
|
385 | 364 | bom=get_bom_with_services_complex(), schema_version=SchemaVersion.V1_1,
|
386 | 365 | fixture='bom_empty.xml'
|
387 | 366 | )
|
388 |
| - mock_uuid_c.assert_called() |
389 |
| - mock_uuid_s.assert_called() |
| 367 | + mock_uuid.assert_called() |
390 | 368 |
|
391 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_6) |
392 |
| - @patch('cyclonedx.model.service.uuid4', side_effect=TEST_UUIDS) |
393 |
| - def test_bom_v1_4_services_nested(self, mock_uuid_c: Mock, mock_uuid_s: Mock) -> None: |
| 369 | + @patch('cyclonedx.model.bom_ref.uuid4', side_effect=TEST_UUIDS) |
| 370 | + def test_bom_v1_4_services_nested(self, mock_uuid: Mock) -> None: |
394 | 371 | self._validate_xml_bom(
|
395 | 372 | bom=get_bom_with_nested_services(), schema_version=SchemaVersion.V1_4,
|
396 | 373 | fixture='bom_services_nested.xml'
|
397 | 374 | )
|
398 |
| - mock_uuid_c.assert_called() |
399 |
| - mock_uuid_s.assert_called() |
| 375 | + mock_uuid.assert_called() |
400 | 376 |
|
401 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_5) |
402 |
| - @patch('cyclonedx.model.service.uuid4', side_effect=TEST_UUIDS) |
403 |
| - def test_bom_v1_3_services_nested(self, mock_uuid_c: Mock, mock_uuid_s: Mock) -> None: |
| 377 | + @patch('cyclonedx.model.bom_ref.uuid4', side_effect=TEST_UUIDS) |
| 378 | + def test_bom_v1_3_services_nested(self, mock_uuid: Mock) -> None: |
404 | 379 | self._validate_xml_bom(
|
405 | 380 | bom=get_bom_with_nested_services(), schema_version=SchemaVersion.V1_3,
|
406 | 381 | fixture='bom_services_nested.xml'
|
407 | 382 | )
|
408 |
| - mock_uuid_c.assert_called() |
409 |
| - mock_uuid_s.assert_called() |
| 383 | + mock_uuid.assert_called() |
410 | 384 |
|
411 |
| - @patch('cyclonedx.model.component.uuid4', return_value=MOCK_UUID_4) |
412 |
| - @patch('cyclonedx.model.service.uuid4', side_effect=TEST_UUIDS) |
413 |
| - def test_bom_v1_2_services_nested(self, mock_uuid_c: Mock, mock_uuid_s: Mock) -> None: |
| 385 | + @patch('cyclonedx.model.bom_ref.uuid4', side_effect=TEST_UUIDS) |
| 386 | + def test_bom_v1_2_services_nested(self, mock_uuid: Mock) -> None: |
414 | 387 | self._validate_xml_bom(
|
415 | 388 | bom=get_bom_with_nested_services(), schema_version=SchemaVersion.V1_2,
|
416 | 389 | fixture='bom_services_nested.xml'
|
417 | 390 | )
|
418 |
| - mock_uuid_c.assert_called() |
419 |
| - mock_uuid_s.assert_called() |
| 391 | + mock_uuid.assert_called() |
420 | 392 |
|
421 | 393 | # Helper methods
|
422 | 394 | def _validate_xml_bom(self, bom: Bom, schema_version: SchemaVersion, fixture: str) -> None:
|
|
0 commit comments