File: test_external_package_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 (35 lines) | stat: -rw-r--r-- 1,210 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
30
31
32
33
34
35
# SPDX-FileCopyrightText: 2023 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0

import pytest

from spdx_tools.spdx.model import ExternalPackageRef, ExternalPackageRefCategory


def test_correct_initialization():
    external_package_reference = ExternalPackageRef(ExternalPackageRefCategory.OTHER, "type", "locator", "comment")
    assert external_package_reference.category == ExternalPackageRefCategory.OTHER
    assert external_package_reference.reference_type == "type"
    assert external_package_reference.locator == "locator"
    assert external_package_reference.comment == "comment"


def test_wrong_type_in_category():
    with pytest.raises(TypeError):
        ExternalPackageRef([ExternalPackageRefCategory.OTHER], "type", "locator")


def test_wrong_type_in_reference_type():
    with pytest.raises(TypeError):
        ExternalPackageRef(ExternalPackageRefCategory.OTHER, 42, "locator")


def test_wrong_type_in_locator():
    with pytest.raises(TypeError):
        ExternalPackageRef(ExternalPackageRefCategory.OTHER, "type", 42)


def test_wrong_type_in_comment():
    with pytest.raises(TypeError):
        ExternalPackageRef(ExternalPackageRefCategory.OTHER, "type", "locator", [])