fix(tempo): delegate user-token worklog path to log_worklog so tests can mock it
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled

This commit is contained in:
kitos
2026-06-25 16:28:16 +02:00
parent 7613f5ec8b
commit f1e0e0acf0
+19 -12
View File
@@ -291,25 +291,32 @@ def auto_log_test_worklog(
from tempoapiclient import client_v4 as tempo_client from tempoapiclient import client_v4 as tempo_client
base_url = _get_tempo_base_url(db) base_url = _get_tempo_base_url(db)
tempo = tempo_client.Tempo(auth_token=admin_token, base_url=base_url) tempo = tempo_client.Tempo(auth_token=admin_token, base_url=base_url)
try:
result = tempo.create_worklog(
accountId=jira_account_id,
issueId=int(link.jira_issue_id),
dateFrom=work_date,
timeSpentSeconds=duration_seconds,
description=description,
)
except BaseException as exc:
raise RuntimeError(f"Tempo API error: {exc}") from exc
elif has_tempo_configured(user): elif has_tempo_configured(user):
tempo = get_user_tempo_client(user, db=db) result = log_worklog(
user,
jira_issue_id=int(link.jira_issue_id),
author_account_id=jira_account_id,
date=work_date,
time_spent_seconds=duration_seconds,
description=description,
db=db,
)
else: else:
logger.debug( logger.debug(
"No Tempo credentials available; skipping worklog for test %s", test.id "No Tempo credentials available; skipping worklog for test %s", test.id
) )
return None return None
try:
result = tempo.create_worklog(
accountId=jira_account_id,
issueId=int(link.jira_issue_id),
dateFrom=work_date,
timeSpentSeconds=duration_seconds,
description=description,
)
except BaseException as exc:
raise RuntimeError(f"Tempo API error: {exc}") from exc
logger.info( logger.info(
"Tempo worklog created for test %s by user %s: %ds on %s", "Tempo worklog created for test %s by user %s: %ds on %s",
test.id, getattr(user, "username", user), duration_seconds, work_date, test.id, getattr(user, "username", user), duration_seconds, work_date,