"""Each case starts the server in a variant and runs `pin.py verify`. PIN=0 simulates a client with no check (loads whatever is offered).""" import datetime, os, subprocess, sys, unittest HERE = os.path.dirname(os.path.abspath(__file__)) def verify(variant, today=None): sub = "verify" if os.environ.get("PIN", "1") == "1" else "load" # PIN=0: connect and load without comparing cmd = [sys.executable, os.path.join(HERE, "pin.py"), sub, "prices"] + (["--today", today] if today else []) p = subprocess.run(cmd, capture_output=True, text=True, env={**os.environ, "VARIANT": variant}); return p.returncode, p.stdout + p.stderr class T(unittest.TestCase): def test_a_unchanged_server_loads(self): self.assertEqual(verify("a")[0], 0) def test_b_description_edit_blocks(self): self.assertEqual(verify("b")[0], 1) def test_c_version_bump_without_entry_blocks(self): self.assertEqual(verify("c")[0], 1) def test_d_added_tool_blocks(self): self.assertEqual(verify("d")[0], 1) def test_e_flipped_annotation_blocks(self): self.assertEqual(verify("e")[0], 1) def test_f_expired_approval_blocks(self): future = (datetime.date.today() + datetime.timedelta(days=91)).isoformat() self.assertEqual(verify("a", future)[0], 1) if __name__ == "__main__": unittest.main(verbosity=2)