Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions liccheck/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ def from_pyproject_toml(cls):
def elements_to_lower_str(lst):
return [str(_).lower() for _ in lst]

conf_keys = {"authorized_licenses", "unauthorized_licenses",
"authorized_packages"}
if not set(liccheck_section.keys()) & conf_keys:
raise NoValidConfigurationInPyprojectToml

strategy = cls(
authorized_licenses=elements_to_lower_str(
liccheck_section.get("authorized_licenses", [])
Expand Down
16 changes: 16 additions & 0 deletions tests/test_read_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def test_falls_back_to_strategy_if_no_liccheck_section_in_pyproject_toml(self):
with pytest.raises(NoValidConfigurationInPyprojectToml):
Strategy.from_pyproject_toml()

@pytest.mark.usefixtures("pyproject_toml_with_liccheck_section_without_licenses_in_cwd")
def test_falls_back_to_strategy_if_liccheck_section_in_pyproject_toml_has_no_licenses(self):
with pytest.raises(NoValidConfigurationInPyprojectToml):
Strategy.from_pyproject_toml()

@pytest.mark.usefixtures("pyproject_toml_with_liccheck_section_in_cwd")
def test_with_liccheck_section_in_pyproject_toml(self):
strategy = Strategy.from_pyproject_toml()
Expand Down Expand Up @@ -58,6 +63,17 @@ def empty_pyproject_toml_in_cwd(self, tmpdir):
yield
os.chdir(cwd)

@pytest.fixture
def pyproject_toml_with_liccheck_section_without_licenses_in_cwd(self, empty_pyproject_toml_in_cwd):
with open("pyproject.toml", "w") as file:
file.write(
"""
[tool.liccheck]
# No licenses are defined here, just point to the strategy file.
strategy_ini_file = "./liccheck.ini"
"""
)

@pytest.fixture
def pyproject_toml_with_liccheck_section_in_cwd(self, empty_pyproject_toml_in_cwd):
with open("pyproject.toml", "w") as file:
Expand Down