Offer catalog sources to inbound-library as shared pointers (IR-WP-0010-T04).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 7780@bnt-lap001 Assistant-Session: 622cd705-cb31-4322-ba08-dd42e44fa583
This commit is contained in:
parent
1d4c55ef25
commit
b1a65e7214
5 changed files with 105 additions and 2 deletions
|
|
@ -118,5 +118,39 @@ class LibraryBriefs(unittest.TestCase):
|
|||
('daily', '2026-10-06', 'complete'))
|
||||
|
||||
|
||||
class ContributeSources(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.root = Path(self.tmp.name) / 'radar'
|
||||
self.library = Path(self.tmp.name) / 'library'
|
||||
(self.root / 'catalog').mkdir(parents=True)
|
||||
(self.library / 'registry' / 'sources').mkdir(parents=True)
|
||||
(self.root / 'catalog' / 'sources.json').write_text(json.dumps({'sources': [
|
||||
{'id': 'swe-bench', 'publisher': 'SWE-bench maintainers',
|
||||
'url': 'https://www.swebench.com/'}]}))
|
||||
self.spec = {'root': str(self.library), 'repo': 'intelligence-radar',
|
||||
'contribute': {'swe-bench': ['ai.benchmarks']}}
|
||||
|
||||
def tearDown(self):
|
||||
self.tmp.cleanup()
|
||||
|
||||
def test_create_then_unchanged_and_pointer_shape(self):
|
||||
self.assertEqual(library_briefs.contribute_sources(self.root, self.spec),
|
||||
[{'source': 'ir-swe-bench', 'status': 'created'}])
|
||||
self.assertEqual(library_briefs.contribute_sources(self.root, self.spec),
|
||||
[{'source': 'ir-swe-bench', 'status': 'unchanged'}])
|
||||
source = json.loads((self.library / 'registry' / 'sources' / 'ir-swe-bench.json').read_text())
|
||||
self.assertEqual((source['channel'], source['url'], source['visibility'], source['topics']),
|
||||
('url', 'https://www.swebench.com/', 'shared', ['ai.benchmarks']))
|
||||
|
||||
def test_refuses_another_repos_file_and_unknown_source(self):
|
||||
(self.library / 'registry' / 'sources' / 'ir-swe-bench.json').write_text(
|
||||
json.dumps({'id': 'ir-swe-bench', 'owner_repo': 'markitect'}))
|
||||
with self.assertRaises(ValueError):
|
||||
library_briefs.contribute_sources(self.root, self.spec)
|
||||
with self.assertRaises(ValueError):
|
||||
library_briefs.contribute_sources(self.root, {**self.spec, 'contribute': {'nope': []}})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue