File: test_snippet_bump.py

package info (click to toggle)
python-spdx-tools 0.8.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,024 kB
  • sloc: python: 18,708; xml: 12,553; sh: 46; makefile: 6
file content (24 lines) | stat: -rw-r--r-- 963 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
24
# SPDX-FileCopyrightText: 2023 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0

from spdx_tools.spdx3.bump_from_spdx2.snippet import bump_snippet
from spdx_tools.spdx3.model.software import Snippet
from spdx_tools.spdx3.payload import Payload
from spdx_tools.spdx.model.snippet import Snippet as Spdx2_Snippet
from tests.spdx.fixtures import snippet_fixture


def test_bump_snippet():
    payload = Payload()
    document_namespace = "https://doc.namespace"
    spdx2_snippet: Spdx2_Snippet = snippet_fixture()
    expected_new_snippet_id = f"{document_namespace}#{spdx2_snippet.spdx_id}"

    bump_snippet(spdx2_snippet, payload, document_namespace, [], [])
    snippet = payload.get_element(expected_new_snippet_id)

    assert isinstance(snippet, Snippet)
    assert snippet.spdx_id == expected_new_snippet_id
    assert snippet.copyright_text == spdx2_snippet.copyright_text
    assert snippet.attribution_text == spdx2_snippet.attribution_texts[0]