|
22 | 22 | from uuid import UUID
|
23 | 23 |
|
24 | 24 | from ddt import ddt, named_data
|
| 25 | +from sortedcontainers import SortedSet |
25 | 26 |
|
26 | 27 | from cyclonedx._internal.compare import ComparableTuple
|
27 | 28 | from cyclonedx.exception.model import InvalidLocaleTypeException, InvalidUriException, UnknownHashTypeException
|
|
39 | 40 | XsUri,
|
40 | 41 | )
|
41 | 42 | from cyclonedx.model.bom_ref import BomRef
|
42 |
| -from cyclonedx.model.contact import OrganizationalContact |
| 43 | +from cyclonedx.model.contact import OrganizationalContact, OrganizationalEntity, PostalAddress |
43 | 44 | from cyclonedx.model.issue import IssueClassification, IssueType, IssueTypeSource
|
44 | 45 | from tests import reorder
|
45 | 46 |
|
@@ -463,6 +464,53 @@ def test_sort(self) -> None:
|
463 | 464 | self.assertListEqual(sorted_contacts, expected_contacts)
|
464 | 465 |
|
465 | 466 |
|
| 467 | +class TestModelOrganizationalEntity(TestCase): |
| 468 | + def test_init_with_bom_ref(self) -> None: |
| 469 | + contacts = [ |
| 470 | + OrganizationalContact(name='a', email='a', phone='a'), |
| 471 | + OrganizationalContact(name='b', email='a', phone='a'), |
| 472 | + ] |
| 473 | + OrganizationalEntity( |
| 474 | + bom_ref=BomRef('dummy-bom-ref'), |
| 475 | + name='dummy-organizational-entity', |
| 476 | + contacts=contacts, |
| 477 | + address=PostalAddress( |
| 478 | + country='dummy-country', |
| 479 | + region='dummy-region', |
| 480 | + ), |
| 481 | + ) |
| 482 | + |
| 483 | + def test_init_without_bom_ref(self) -> None: |
| 484 | + contacts = [ |
| 485 | + OrganizationalContact(name='a', email='a', phone='a'), |
| 486 | + OrganizationalContact(name='b', email='a', phone='a'), |
| 487 | + ] |
| 488 | + OrganizationalEntity( |
| 489 | + name='dummy-organizational-entity', |
| 490 | + contacts=contacts, |
| 491 | + address=PostalAddress( |
| 492 | + country='dummy-country', |
| 493 | + region='dummy-region', |
| 494 | + ), |
| 495 | + ) |
| 496 | + |
| 497 | + def test_init_from_json(self) -> None: |
| 498 | + bom_ref = 'Example' |
| 499 | + name = 'Example' |
| 500 | + urls = [ |
| 501 | + 'https://example.com/' |
| 502 | + ] |
| 503 | + specification = { |
| 504 | + 'name': name, |
| 505 | + 'url': urls, |
| 506 | + 'bom-ref': bom_ref |
| 507 | + } |
| 508 | + entity = OrganizationalEntity.from_json(specification) |
| 509 | + assert entity.name == name |
| 510 | + assert entity.urls == SortedSet([XsUri(url) for url in urls]) |
| 511 | + assert entity.bom_ref == BomRef(bom_ref) |
| 512 | + |
| 513 | + |
466 | 514 | class TestModelXsUri(TestCase):
|
467 | 515 |
|
468 | 516 | # URI samples taken from http://www.datypic.com/sc/xsd/t-xsd_anyURI.html
|
|
0 commit comments