[verified] Canonicalize native review publication journals
This commit is contained in:
@@ -93,6 +93,11 @@ class IntegrationTests(unittest.TestCase):
|
||||
SCRATCH.mkdir(parents=True, exist_ok=True)
|
||||
self.tmp = tempfile.TemporaryDirectory(dir=SCRATCH)
|
||||
self.ev = RealEvidence(Path(self.tmp.name))
|
||||
from unittest.mock import patch as mock_patch
|
||||
self.registry_patch = mock_patch.object(native._journal, 'root_for',
|
||||
return_value=Path(self.tmp.name) / 'native-review-journals')
|
||||
self.registry_patch.start()
|
||||
self.addCleanup(self.registry_patch.stop)
|
||||
|
||||
def tearDown(self): self.tmp.cleanup()
|
||||
|
||||
@@ -160,9 +165,9 @@ class IntegrationTests(unittest.TestCase):
|
||||
self.ev.set_stage('code-review')
|
||||
fixture, plan, before, after, exact = self.bound_publication_fixture()
|
||||
api = fixture.FakeAPI(plan, before, after, exact)
|
||||
with tempfile.TemporaryDirectory(dir=self.tmp.name) as journal:
|
||||
first = native.publish(plan, before, api, fixture.FakeLease(), journal, declaration=self.ev.declaration())
|
||||
second = native.publish(plan, before, api, fixture.FakeLease(), journal, declaration=self.ev.declaration())
|
||||
journal = native.canonical_journal_path(plan)
|
||||
first = native.publish(plan, before, api, fixture.FakeLease(), journal, declaration=self.ev.declaration())
|
||||
second = native.publish(plan, before, api, fixture.FakeLease(), journal, declaration=self.ev.declaration())
|
||||
self.assertEqual(first['mode'], 'created')
|
||||
self.assertEqual(second['mode'], 'no_op')
|
||||
self.assertEqual(api.posts, 1)
|
||||
@@ -180,17 +185,17 @@ class IntegrationTests(unittest.TestCase):
|
||||
self.ev.bundle.joinpath('src/a.py').write_text('VALUE = 9\n')
|
||||
return out
|
||||
api.snapshot = mutating_snapshot
|
||||
with tempfile.TemporaryDirectory(dir=self.tmp.name) as journal:
|
||||
with self.assertRaisesRegex(native.ValidationError, 'delegation adoption'):
|
||||
native.publish(plan, before, api, fixture.FakeLease(), journal, declaration=self.ev.declaration())
|
||||
self.assertEqual(calls['n'], 2, 'must reach both provider reads and final adoption check')
|
||||
self.assertTrue((Path(journal) / 'intent.json').exists())
|
||||
self.assertEqual(api.posts, 0)
|
||||
# Conservatively preserve durable intent: restoring evidence cannot trigger POST.
|
||||
self.ev.bundle.joinpath('src/a.py').write_text('VALUE = 1\n')
|
||||
with self.assertRaises(native.UncertainPublication):
|
||||
native.publish(plan, before, api, fixture.FakeLease(), journal, declaration=self.ev.declaration())
|
||||
self.assertEqual(api.posts, 0)
|
||||
journal = native.canonical_journal_path(plan)
|
||||
with self.assertRaisesRegex(native.ValidationError, 'delegation adoption'):
|
||||
native.publish(plan, before, api, fixture.FakeLease(), journal, declaration=self.ev.declaration())
|
||||
self.assertEqual(calls['n'], 2, 'must reach both provider reads and final adoption check')
|
||||
self.assertTrue((Path(journal) / 'intent.json').exists())
|
||||
self.assertEqual(api.posts, 0)
|
||||
# Conservatively preserve durable intent: restoring evidence cannot trigger POST.
|
||||
self.ev.bundle.joinpath('src/a.py').write_text('VALUE = 1\n')
|
||||
with self.assertRaises(native.UncertainPublication):
|
||||
native.publish(plan, before, api, fixture.FakeLease(), journal, declaration=self.ev.declaration())
|
||||
self.assertEqual(api.posts, 0)
|
||||
|
||||
def spec_result(self):
|
||||
return {'schema': support.SCHEMA,
|
||||
@@ -241,7 +246,7 @@ class IntegrationTests(unittest.TestCase):
|
||||
self.ev.set_stage('code-review')
|
||||
fixture, plan, before, after, exact = self.bound_publication_fixture()
|
||||
api = fixture.FakeAPI(plan, before, after, exact)
|
||||
journal = Path(self.tmp.name) / ('denied-journal-' + mode)
|
||||
journal = native.canonical_journal_path(plan)
|
||||
with self.subTest(mode=mode, consumer='review'):
|
||||
with self.assertRaises(native.ValidationError):
|
||||
native.publish(plan, before, api, fixture.FakeLease(), journal, declaration=declaration)
|
||||
|
||||
Reference in New Issue
Block a user