# SPDX-FileCopyrightText: Defame1297 and contributors # SPDX-License-Identifier: GPL-3.0-or-later """Run with: python3 -m unittest discover -s tests/scripts""" import pathlib import sys import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2] / "scripts")) import check_tarball # noqa: E402 class TarballTest(unittest.TestCase): def test_clean(self): self.assertEqual(check_tarball.problems( ["README.md", "roles/", "roles/a/tasks/main.yml", "LICENSES/MIT.txt", "tests/sanity/x.txt"]), []) def test_stray_top_level(self): for name in (".venv/lib/a.py", "CLAUDE.md", ".claude/settings.json", "importer_result.json", "extensions/m.yml"): self.assertEqual(len(check_tarball.problems([name])), 1, name) def test_forbidden_inside_allowed(self): self.assertEqual(len(check_tarball.problems(["roles/a/molecule/default/molecule.yml"])), 1) self.assertEqual(len(check_tarball.problems(["roles/a/files/k.pem"])), 1) self.assertEqual(len(check_tarball.problems(["tests/scripts/t.py"])), 1) if __name__ == "__main__": unittest.main()