#!/usr/bin/env python3 # Copyright: 2026, Maximiliano Curia # # License: ISC # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # . # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. """Structural guards for the LICENSES_RES rule table wiring.""" import unittest from decopy.licensing import res class TestLicensesResWiring(unittest.TestCase): """LICENSES_RES is the single, fully-wired public rule table. Guards the two-pass wiring (exception_subs, then get_detail) that builds the public tuple from the raw table: every rule of a family that declares a family-level callback must end up carrying it. """ def test_compiled_res_aligns_with_rule_table(self): self.assertEqual(len(res.COMPILED_RES), len(res.LICENSES_RES)) def test_family_detail_is_wired_onto_every_family_rule(self): for rule in res.LICENSES_RES: if rule.license in res._FAMILY_DETAIL: self.assertIsNotNone( rule.get_detail, f"{rule.license} rule missing wired get_detail", ) def test_family_exception_subs_is_wired_onto_every_family_rule(self): for rule in res.LICENSES_RES: if rule.license in res._FAMILY_EXCEPTION_SUBS: self.assertIsNotNone( rule.exception_subs, f"{rule.license} rule missing wired exception_subs", ) def test_public_table_is_not_the_raw_table(self): # The public tuple is the wired result, distinct from the raw literal. self.assertIsNot(res.LICENSES_RES, res._RAW_LICENSES_RES) self.assertEqual(len(res.LICENSES_RES), len(res._RAW_LICENSES_RES)) if __name__ == "__main__": unittest.main()