File: test_external_document_ref.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 (34 lines) | stat: -rw-r--r-- 1,028 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
# SPDX-FileCopyrightText: 2023 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0

from unittest import mock

import pytest

from spdx_tools.spdx.model import ExternalDocumentRef


@mock.patch("spdx_tools.spdx.model.Checksum", autospec=True)
def test_correct_initialization(checksum):
    external_document_ref = ExternalDocumentRef("id", "uri", checksum)
    assert external_document_ref.document_ref_id == "id"
    assert external_document_ref.document_uri == "uri"
    assert external_document_ref.checksum == checksum


@mock.patch("spdx_tools.spdx.model.Checksum", autospec=True)
def test_wrong_type_in_spdx_id(checksum):
    with pytest.raises(TypeError):
        ExternalDocumentRef(42, "uri", checksum)


@mock.patch("spdx_tools.spdx.model.Checksum", autospec=True)
def test_wrong_type_in_document_uri(checksum):
    with pytest.raises(TypeError):
        ExternalDocumentRef("id", 42, checksum)


def test_wrong_type_in_checksum():
    with pytest.raises(TypeError):
        ExternalDocumentRef("id", "uri", 42)