test_license_policy.py file-level

at sha256:1 · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:1 Document cross-repo training status Add the Scooling, Knowtation, and … · · Jun 10, 2026
1 """Unit tests for dependency license policy checks."""
2
3 from unittest import TestCase
4
5 from scooling_lab.license_policy import (
6 DependencyEntry,
7 audit_dependency_entries,
8 is_allowed_source_path,
9 is_approved_license,
10 )
11
12
13 class LicensePolicyTests(TestCase):
14 """Validate the initial Apache-compatible dependency policy."""
15
16 def test_permissive_license_ids_are_allowed(self) -> None:
17 self.assertTrue(is_approved_license("Apache-2.0"))
18 self.assertTrue(is_approved_license("MIT"))
19 self.assertFalse(is_approved_license("AGPL-3.0"))
20
21 def test_agpl_component_paths_are_blocked(self) -> None:
22 self.assertTrue(is_allowed_source_path("unsloth/models/loader.py"))
23 self.assertFalse(is_allowed_source_path("studio/app.py"))
24 self.assertFalse(is_allowed_source_path("unsloth_cli/train.py"))
25
26 def test_audit_splits_accepted_and_rejected_entries(self) -> None:
27 accepted = DependencyEntry(
28 name="candidate-core",
29 license_id="Apache-2.0",
30 source_path="unsloth/core.py",
31 )
32 rejected = DependencyEntry(
33 name="candidate-studio",
34 license_id="AGPL-3.0",
35 source_path="studio/app.py",
36 )
37
38 result = audit_dependency_entries((accepted, rejected))
39
40 self.assertFalse(result.ok)
41 self.assertEqual(result.accepted, (accepted,))
42 self.assertEqual(result.rejected, (rejected,))