03-oct: superguardado automático
This commit is contained in:
58
tests/test_jira.py
Normal file
58
tests/test_jira.py
Normal file
@@ -0,0 +1,58 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Tests de `monitor_estado.fuentes.jira` — DS nuevos y sin asignar, solo GET (RF-3, RF-4, RF-16)."""
|
||||
|
||||
import monitor_estado.fuentes.jira as jira
|
||||
|
||||
|
||||
def _issue(key, summary, status="Pendiente", created="2026-10-03T08:00:00.000+0200"):
|
||||
return {"key": key, "fields": {
|
||||
"summary": summary,
|
||||
"status": {"name": status},
|
||||
"created": created,
|
||||
"priority": {"name": "Media"},
|
||||
}}
|
||||
|
||||
|
||||
class FakeJira:
|
||||
"""Solo implementa `search` (lectura). Si el codigo intentara escribir, fallaria."""
|
||||
|
||||
def __init__(self):
|
||||
self.calls = []
|
||||
|
||||
def search(self, jql, fields=None, max_results=50):
|
||||
self.calls.append(jql)
|
||||
if "assignee = EMPTY" in jql:
|
||||
issues = [_issue("DS-100", "Ticket sin asignar")]
|
||||
elif "created >=" in jql:
|
||||
issues = [_issue("DS-200", "Ticket nuevo")]
|
||||
else:
|
||||
issues = []
|
||||
return {"issues": issues}
|
||||
|
||||
|
||||
def test_jira_jql_ds_sin_asignar():
|
||||
fake = FakeJira()
|
||||
out = jira.ds_sin_asignar(fake)
|
||||
assert any("assignee = EMPTY" in c and "project = DS" in c for c in fake.calls)
|
||||
assert out[0]["key"] == "DS-100"
|
||||
assert out[0]["estado"] == "Pendiente"
|
||||
|
||||
|
||||
def test_jira_ds_nuevos_ventana():
|
||||
fake = FakeJira()
|
||||
out = jira.ds_nuevos(fake, "2026-10-03 00:00")
|
||||
assert "created >=" in fake.calls[-1]
|
||||
assert out[0]["key"] == "DS-200"
|
||||
|
||||
|
||||
def test_jira_solo_lectura():
|
||||
"""El cliente usado solo expone `search` (no hay escritura) — RF-16."""
|
||||
fake = FakeJira()
|
||||
jira.ds_sin_asignar(fake)
|
||||
jira.ds_nuevos(fake, "2026-10-03 00:00")
|
||||
assert not hasattr(fake, "create_issue") and not hasattr(fake, "post")
|
||||
|
||||
|
||||
def test_render_jira():
|
||||
txt = jira.render_jira({"key": "DS-1", "resumen": "Algo", "estado": "Pendiente", "url": "u"})
|
||||
assert "DS-1" in txt and "Algo" in txt and "Pendiente" in txt
|
||||
Reference in New Issue
Block a user