feat: fold bot-bottle-orchestrator into bot_bottle/orchestrator subpackage
Moves the orchestrator into bot_bottle/orchestrator/ so one install gets everything. Entry point is now `python -m bot_bottle.orchestrator run`. - Add bot_bottle/orchestrator/ with all 14 modules (verbatim move; internal imports were already relative, so no changes inside orchestrator modules) - Rewrite bootstrap.py: remove the lazy bot_bottle import guard, use direct relative imports from ..contrib.* - Add bot_bottle/contrib/forge/base.py: ScopedForge (read-anywhere / write-scoped) - Add bot_bottle/contrib/gitea/client.py: GiteaClient + GiteaForge (urllib.request only) - Add bot_bottle/contrib/gitea/forge_state.py: ForgeState + SqliteForgeStateStore - Add tests/unit/orchestrator/ (82 tests: 63 migrated + 19 new for contrib modules) Closes #321
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
"""Unit: InMemoryStateStore."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from bot_bottle.orchestrator.model import RunRecord
|
||||
from bot_bottle.orchestrator.store import InMemoryStateStore
|
||||
|
||||
|
||||
def _rec(issue: int, owner: str = "o") -> RunRecord:
|
||||
return RunRecord(owner=owner, repo="r", issue_number=issue, slug=f"s{issue}",
|
||||
agent_name="a")
|
||||
|
||||
|
||||
class InMemoryStoreTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.store = InMemoryStateStore()
|
||||
|
||||
def test_upsert_get(self):
|
||||
self.store.upsert(_rec(1))
|
||||
got = self.store.get("o", "r", 1)
|
||||
assert got is not None
|
||||
self.assertEqual("s1", got.slug)
|
||||
|
||||
def test_get_missing(self):
|
||||
self.assertIsNone(self.store.get("o", "r", 99))
|
||||
|
||||
def test_upsert_replaces(self):
|
||||
self.store.upsert(_rec(1))
|
||||
r = _rec(1)
|
||||
r.slug = "changed"
|
||||
self.store.upsert(r)
|
||||
self.assertEqual("changed", self.store.get("o", "r", 1).slug) # type: ignore[union-attr]
|
||||
self.assertEqual(1, len(self.store.all()))
|
||||
|
||||
def test_delete(self):
|
||||
self.store.upsert(_rec(1))
|
||||
self.store.delete("o", "r", 1)
|
||||
self.assertIsNone(self.store.get("o", "r", 1))
|
||||
|
||||
def test_all_sorted(self):
|
||||
self.store.upsert(_rec(2, owner="b"))
|
||||
self.store.upsert(_rec(1, owner="a"))
|
||||
self.assertEqual([("a", 1), ("b", 2)],
|
||||
[(r.owner, r.issue_number) for r in self.store.all()])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user