import re
import unittest
from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]


class PackageContractTests(unittest.TestCase):
    def test_move_clock_provider_is_a_declared_dependency(self):
        spec = (ROOT / "stillcontrol.spec").read_text(encoding="utf-8")
        readme = (ROOT / "README.md").read_text(encoding="utf-8")

        self.assertRegex(spec, r"(?m)^Requires:\s+gnome-shell-frippery\s*$")
        self.assertIn("gnome-shell-frippery", readme)

    def test_package_release_is_bumped_for_layout_updates(self):
        spec = (ROOT / "stillcontrol.spec").read_text(encoding="utf-8")

        self.assertRegex(spec, r"(?m)^Version:\s+10\.2\.7\s*$")
        self.assertRegex(spec, r"(?m)^Release:\s+5%\{\?dist\}\s*$")


if __name__ == "__main__":
    unittest.main()
