This commit is contained in:
eddiesoehnel committed 2026-10-06 14:47:01 -06:00
commit 8313c5c6b5
84 files changed
+4337

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
import unittest
from types import SimpleNamespace
from unittest.mock import patch
from scheduling_core.mcp_stdio import Adapter
class SupervisedSendScopeTests(unittest.TestCase):
def setUp(self):
self.scope = {'transaction_id':'approved-test', 'requester':'[email protected]', 'owner':'[email protected]'}
self.policy = SimpleNamespace(owner_email='[email protected]')
self.adapter = Adapter(object(), self.policy, object(), supervised_send_scope=self.scope)
self.args = {'transaction_id':'approved-test', 'lease_token':'lease', 'operation_key':'operation', 'sender':'[email protected]', 'requester':'[email protected]', 'purpose':'offer'}
def test_other_transaction_and_recipient_rejected_before_ledger_or_transport(self):
for change in ({'transaction_id':'other'}, {'requester':'[email protected]'}, {'purpose':'owner_summary'}):
with self.subTest(change=change), patch('scheduling_core.mcp_stdio.SchedulingWorkflow', side_effect=AssertionError('Ledger must not be accessed')):
with self.assertRaisesRegex(ValueError, 'outside the approved'):
self.adapter.call('prepare_postmark_send', {**self.args, **change})
def test_approved_requester_and_owner_continue_to_existing_safeguards(self):
for change in ({}, {'purpose':'confirmation'}, {'purpose':'owner_summary','requester':'[email protected]'}):
with self.subTest(change=change), patch('scheduling_core.mcp_stdio.SchedulingWorkflow', side_effect=RuntimeError('Existing safeguards reached')):
with self.assertRaisesRegex(RuntimeError, 'Existing safeguards reached'):
self.adapter.call('prepare_postmark_send', {**self.args, **change})
def test_incomplete_scope_and_different_owner_fail_closed(self):
for scope in ({'transaction_id':'approved-test'}, {**self.scope,'owner':'[email protected]'}):
with self.subTest(scope=scope), self.assertRaises(ValueError):
Adapter(object(), self.policy, object(), supervised_send_scope=scope)