File: test_external_reference.py

package info (click to toggle)
python-spdx-tools 0.8.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 5,084 kB
  • sloc: python: 18,675; xml: 12,553; sh: 46; makefile: 6
file content (29 lines) | stat: -rw-r--r-- 1,117 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# SPDX-FileCopyrightText: 2023 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
import pytest

from spdx_tools.spdx3.model import ExternalReference, ExternalReferenceType
from tests.spdx3.fixtures import external_reference_fixture
from tests.spdx3.model.model_test_utils import get_property_names


def test_correct_initialization():
    external_reference = external_reference_fixture()

    for property_name in get_property_names(ExternalReference):
        assert getattr(external_reference, property_name) is not None

    assert external_reference.external_reference_type == ExternalReferenceType.OTHER
    assert external_reference.locator == ["org.apache.tomcat:tomcat:9.0.0.M4"]
    assert external_reference.content_type == "externalReferenceContentType"
    assert external_reference.comment == "externalReferenceComment"


def test_invalid_initialization():
    with pytest.raises(TypeError) as err:
        ExternalReference("OTHER", "a URI", 34, True)

    assert len(err.value.args[0]) == 4
    for error in err.value.args[0]:
        assert error.startswith("SetterError ExternalReference:")