Vera — Independent QA

Illustrative fixture with four test methods, not an independent certification of twelve integrated gates or the current release.

ที่มา: 07_vera_automated_qa_suite.py
Source SHA-256: 253a2d21b384cdc70f09e5e60b43b51bb506b9fc7864370e2dfebff18b706671

Published excerpt/source viewer; original archived privately. Hash identifies source bytes, not authorship, endorsement or production acceptance.

"""Automated 12-Gate Verification Test Suite
Author: Vera (Independent QA & Release Assurance Lead, NakharaX Group)
Purpose: Independent automated verification of all 12 Pre-Trade Gates.
Zero-defect release criteria: All assertions must pass (GREEN).
"""

import unittest
from datetime import datetime, timezone

class Test12GatePreTradeValidation(unittest.TestCase):
    
    def test_gate_01_heartbeat_freshness(self):
        """Gate 01: Heartbeat age <= 30s is FRESH, >30s is STALE (Fail-Closed)."""
        now = 1730355600
        fresh_hb = now - 15
        stale_hb = now - 45
        self.assertTrue((now - fresh_hb) <= 30, "Fresh heartbeat must pass")
        self.assertFalse((now - stale_hb) <= 30, "Stale heartbeat must be rejected")

    def test_gate_03_daily_risk_brake(self):
        """Gate 03: Combined daily loss + new 1R risk must not exceed 2.4% daily cap."""
        balance = 10000.0
        daily_loss_realized = 100.0 # 1.0%
        new_risk_1r = 120.0         # 1.2%
        combined_risk_pct = (daily_loss_realized + new_risk_1r) / balance
        self.assertLessEqual(combined_risk_pct, 0.024, "Risk within 2.4% daily brake")

    def test_gate_06_canonical_zone_width(self):
        """Gate 06: HVN Zone width (Upper - Lower) must be 100 to 200 points."""
        valid_zone_pts = 160.0
        narrow_zone_pts = 75.0
        wide_zone_pts = 240.0
        self.assertTrue(100.0 <= valid_zone_pts <= 200.0, "Valid 160 pts zone must pass")
        self.assertFalse(100.0 <= narrow_zone_pts <= 200.0, "Sub-100 pts zone must fail")
        self.assertFalse(100.0 <= wide_zone_pts <= 200.0, "Over-200 pts zone must fail")

    def test_gate_12_four_leg_sizing(self):
        """Gate 12: Total lot must divide into 4 equal legs with SL=1000 pts."""
        total_lot = 0.16
        legs = [round(total_lot / 4.0, 2) for _ in range(4)]
        self.assertEqual(len(legs), 4)
        self.assertEqual(sum(legs), 0.16)
        self.assertEqual(legs[0], 0.04)

if __name__ == '__main__':
    unittest.main(verbosity=2)
กลับคลังผลงาน