|
| 1 | +# |
| 2 | +# Copyright (c) nexB Inc. and others. All rights reserved. |
| 3 | +# ScanCode is a trademark of nexB Inc. |
| 4 | +# SPDX-License-Identifier: Apache-2.0 |
| 5 | +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. |
| 6 | +# See https://github.com/nexB/scancode-toolkit for support or download. |
| 7 | +# See https://aboutcode.org for more information about nexB OSS projects. |
| 8 | +# |
| 9 | + |
| 10 | +from os.path import dirname |
| 11 | +from os.path import join |
| 12 | + |
| 13 | +try: |
| 14 | + import tomli as tomllib |
| 15 | +except ImportError: |
| 16 | + import tomllib |
| 17 | + |
| 18 | + |
| 19 | +root_dir = dirname(dirname(dirname(__file__))) |
| 20 | + |
| 21 | +release_pyprojects = ( |
| 22 | + "pyproject-scancode-toolkit.toml", |
| 23 | + "pyproject-scancode-toolkit-mini.toml", |
| 24 | +) |
| 25 | + |
| 26 | +scancode_pyprojects = release_pyprojects + ("pyproject.toml",) |
| 27 | + |
| 28 | + |
| 29 | +def load_project(pyproject): |
| 30 | + with open(join(root_dir, pyproject), "rb") as inp: |
| 31 | + pyproject_data = tomllib.load(inp) |
| 32 | + return pyproject_data["project"] |
| 33 | + |
| 34 | + |
| 35 | +def test_scancode_release_wheels_depend_on_license_data_package(): |
| 36 | + for pyproject in release_pyprojects: |
| 37 | + dependencies = load_project(pyproject)["dependencies"] |
| 38 | + |
| 39 | + assert "licensedcode-data" in dependencies |
| 40 | + assert "licensedcode-index" in dependencies |
| 41 | + |
| 42 | + |
| 43 | +def test_scancode_license_extra_uses_licensedcode_data_package(): |
| 44 | + for pyproject in scancode_pyprojects: |
| 45 | + license_dependencies = load_project(pyproject)["optional-dependencies"][ |
| 46 | + "licenses" |
| 47 | + ] |
| 48 | + |
| 49 | + assert "licensedcode-data" in license_dependencies |
| 50 | + assert "licensecode-data" not in license_dependencies |
0 commit comments