a486e41068
# Conflicts: # README.md # bin/do_epic/backend/fake.py # bin/do_epic/backend/jira.py # bin/do_epic/backend/protocol.py # bin/do_epic/backend/test_fake.py # bin/do_epic/backend/test_jira.py
56 lines
2.2 KiB
Python
56 lines
2.2 KiB
Python
import pathlib
|
|
import sys
|
|
import unittest
|
|
|
|
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
|
|
|
|
from do_epic.backend.contract import EpicStoreContract
|
|
from failure import Failure
|
|
from plan_store import jira_epic
|
|
from do_epic.backend.fake import MemoryEpic
|
|
|
|
|
|
class MemoryEpicContract(EpicStoreContract, unittest.TestCase):
|
|
def new_store(self) -> MemoryEpic:
|
|
return MemoryEpic("ABC-12")
|
|
|
|
def assign(self, store: MemoryEpic, key: str, name: str) -> None: # type: ignore[override]
|
|
store.change(key, assignee=name)
|
|
|
|
def comments_on(self, store: MemoryEpic, key: str) -> list[str]: # type: ignore[override]
|
|
return store.comments.get(key, [])
|
|
|
|
def close(self, store: MemoryEpic, key: str, status: str) -> None: # type: ignore[override]
|
|
store.change(key, status=status, done=True)
|
|
|
|
def person_files(self, store: MemoryEpic, summary: str) -> str: # type: ignore[override]
|
|
key = self.filed(store, store.epic_key, summary)
|
|
store.change(key, by_loop=False)
|
|
return key
|
|
|
|
def score(self, store: MemoryEpic, key: str, scores: dict[str, object]) -> None: # type: ignore[override]
|
|
read = jira_epic.scores(key, scores)
|
|
assert not isinstance(read, Failure), read
|
|
store.change(key, scores=read.scores, moves=read.moves, exempt=read.exempt)
|
|
|
|
def block(self, store: MemoryEpic, key: str, blocker: str) -> None: # type: ignore[override]
|
|
store.change(key, blockers=(*next(issue for issue in store.issues if issue.key == key).blockers, blocker))
|
|
|
|
|
|
class Failing(unittest.TestCase):
|
|
def test_every_read_filing_label_comment_and_rank_fails_with_the_reason_given(self) -> None:
|
|
store = MemoryEpic("ABC-12", fails="Jira is down")
|
|
down = Failure("Jira is down")
|
|
self.assertEqual((store.read(), store.file("ABC-12", "Count the runs.", "", ()), store.add_label("ABC-100", "api"), store.comment("ABC-100", "Hello."), store.rank("ABC-100", "ABC-101")), (down,) * 5)
|
|
|
|
|
|
class Ranking(unittest.TestCase):
|
|
def test_refuses_to_rank_beside_an_issue_that_isnt_a_child_of_the_epic(self) -> None:
|
|
store = MemoryEpic("ABC-12")
|
|
child = store.file("ABC-12", "Count the runs.", "", ())
|
|
self.assertEqual(store.rank(str(child), "ZZZ-1"), Failure(f"ZZZ-1 is not one of the child issues of the epic ABC-12, so {child} is not ranked"))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|