File: test_checksum.py

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

import pytest

from spdx_tools.spdx.model import Checksum, ChecksumAlgorithm


def test_correct_initialization():
    checksum = Checksum(ChecksumAlgorithm.BLAKE2B_256, "value")
    assert checksum.algorithm == ChecksumAlgorithm.BLAKE2B_256
    assert checksum.value == "value"


def test_wrong_type_in_algorithm():
    with pytest.raises(TypeError):
        Checksum(42, "value")


def test_wrong_type_in_value():
    with pytest.raises(TypeError):
        Checksum(ChecksumAlgorithm.BLAKE2B_256, 42)