test(palier-1): 16 tests — journal, métriques, détail, âge, WIP (52 verts)

FakeGitea étendu (get_issue, commentaires); le test de réconciliation
suit le nouveau retour de reconcile_board_state; l'assertion de
version suit APP_VERSION.
This commit is contained in:
Spark
2026-10-11 10:05:51 -04:00
parent 9bf24da04e
commit f1dd921e63
4 changed files with 234 additions and 2 deletions
+46
View File
@@ -45,10 +45,15 @@ def _issue(number: int, title: str, state: str = "open", pr: bool = False) -> di
issue = {
"number": number,
"title": title,
"body": f"Corps de l'issue {number} en **markdown**.",
"state": state,
"labels": [{"name": "bug", "color": "ff0000"}] if number == 1 else [],
"assignee": None,
"assignees": [],
"milestone": None,
"due_date": None,
"created_at": "2026-09-01T09:00:00Z",
"updated_at": "2026-09-02T09:00:00Z",
"html_url": f"http://gitea.test/Projets/demo/issues/{number}",
}
if pr:
@@ -76,6 +81,19 @@ class FakeGitea:
}
self.state_changes: list[tuple] = []
self.created: list[tuple] = []
self.comments: dict[tuple, list[dict]] = {
("Projets/demo", 1): [
{
"id": 1,
"body": "Premier commentaire",
"created_at": "2026-09-03T10:00:00Z",
"updated_at": "2026-09-03T10:00:00Z",
"html_url": "http://gitea.test/comment/1",
"user": {"login": "bruno", "avatar_url": ""},
}
],
}
self.posted_comments: list[tuple] = []
self.ping_result = True
self.raise_on_search = False
self.fail_state_change = False
@@ -105,6 +123,33 @@ class FakeGitea:
items = [i for i in items if i["state"] == state]
return items
async def get_issue(self, owner, repo, number):
import httpx as _httpx
for issue in self.issues.get(f"{owner}/{repo}", []):
if issue["number"] == number:
return issue
request = _httpx.Request("GET", "http://gitea.test")
raise _httpx.HTTPStatusError(
"404", request=request, response=_httpx.Response(404, request=request)
)
async def get_issue_comments(self, owner, repo, number):
return list(self.comments.get((f"{owner}/{repo}", number), []))
async def create_comment(self, owner, repo, number, body):
comment = {
"id": 500 + len(self.posted_comments),
"body": body,
"created_at": "2026-10-11T10:00:00Z",
"updated_at": "2026-10-11T10:00:00Z",
"html_url": "http://gitea.test/comment/new",
"user": {"login": "bruno", "avatar_url": ""},
}
self.comments.setdefault((f"{owner}/{repo}", number), []).append(comment)
self.posted_comments.append((owner, repo, number, body))
return comment
async def create_issue(self, owner, repo, title, body=""):
self._next_number += 1
issue = _issue(self._next_number, title)
@@ -129,6 +174,7 @@ def clean_db():
with models.get_db() as conn:
conn.execute("DELETE FROM board_state")
conn.execute("DELETE FROM project_notes")
conn.execute("DELETE FROM board_events")
yield