From 53189531508bafd44b551c175045557add0a5571 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Thu, 11 Mar 2021 10:36:26 +0200 Subject: [PATCH] tests/test_check.py: Add tests for licenses --- tests/test_check.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_check.py b/tests/test_check.py index 4ce3c34..58d4a94 100644 --- a/tests/test_check.py +++ b/tests/test_check.py @@ -336,3 +336,27 @@ def test_check_correct_iso_639_3_language(): result = experimental.correct_language(series) assert result == language + + +def test_check_valid_spdx_license_identifier(): + """Test valid SPDX license identifier.""" + + license = "CC-BY-SA-4.0" + + result = check.spdx_license_identifier(license) + + assert result == license + + +def test_check_invalid_spdx_license_identifier(capsys): + """Test invalid SPDX license identifier.""" + + license = "CC-BY-SA" + + result = check.spdx_license_identifier(license) + + captured = capsys.readouterr() + assert ( + captured.out + == f"{Fore.YELLOW}Non-SPDX license identifier: {Fore.RESET}{license}\n" + )