Download assigned tasks; skip only "Facesheets Needed (GG)"
Tasks assigned to someone (BT, SM, ...) were skipped, so their facesheets were never downloaded. Only GG tasks must be skipped now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bfd72825b4
commit
3e7cc4afe9
2 files changed
+66
-45
No files matched your search
@@ -1,7 +1,7 @@
|
||||
"""Only unassigned Not-Started tasks may be downloaded.
|
||||
"""Assigned tasks download like any other; only "Facesheets Needed (GG)" is skipped.
|
||||
|
||||
A task carrying an 'Assigned to' avatar in the Planner grid has been picked up
|
||||
by a person; the bot must leave it — and its status — alone.
|
||||
A task assigned to someone (BT, SM, ...) with a facesheet attached must still be
|
||||
downloaded. GG tasks are never downloaded and their status is never touched.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -16,7 +16,7 @@ for _p in (str(ROOT), str(SRC)):
|
||||
if _p not in sys.path:
|
||||
sys.path.insert(0, _p)
|
||||
|
||||
from onedrive_planner_http import _task_assignee_ids, _write_summary # noqa: E402
|
||||
from onedrive_planner_http import _is_gg_task, _task_assignee_ids, _write_summary # noqa: E402
|
||||
|
||||
|
||||
class TestTaskAssigneeIds:
|
||||
@@ -42,6 +42,20 @@ class TestTaskAssigneeIds:
|
||||
assert _task_assignee_ids({"assignments": {"": {}}}) == []
|
||||
|
||||
|
||||
class TestGgSkip:
|
||||
def test_gg_title_is_skipped(self):
|
||||
assert _is_gg_task({"title": "Facesheets Needed (GG)"})
|
||||
assert _is_gg_task({"title": " facesheets needed (gg) "})
|
||||
|
||||
def test_assigned_non_gg_task_is_downloaded(self):
|
||||
# Reo Vista / Balboa misses: assigned to BT / SM, must NOT be skipped.
|
||||
assert not _is_gg_task({"title": "10.26.26", "assignments": {"u1": {}}})
|
||||
assert not _is_gg_task(
|
||||
{"title": "Melzer, Gilbert 8/23/63-Need Medi-Cal ID", "assignments": {"u2": {}}}
|
||||
)
|
||||
assert not _is_gg_task({"title": None})
|
||||
|
||||
|
||||
class TestSummaryWorkbook:
|
||||
def _write(self, tmp_path: Path, payload: dict) -> Path:
|
||||
out = tmp_path / "Download_Summary_HTTP_test.xlsx"
|
||||
@@ -49,18 +63,18 @@ class TestSummaryWorkbook:
|
||||
return out
|
||||
|
||||
def _balboa_payload(self) -> dict:
|
||||
"""The real Balboa plan: 2 unassigned with files, 2 assigned."""
|
||||
"""The real Balboa plan: 2 downloaded (one assigned), 2 GG skipped."""
|
||||
return {
|
||||
"original": [Path("a.pdf"), Path("b.pdf")],
|
||||
"tasks_total": 4,
|
||||
"tasks_with_attachments": 2,
|
||||
"tasks_with_downloads": 2,
|
||||
"tasks_skipped_no_attachment": 0,
|
||||
"tasks_skipped_assigned": 2,
|
||||
"tasks_skipped_gg": 2,
|
||||
"status_changed": 2,
|
||||
"task_rows": [
|
||||
{"Facility Name": "Balboa Nursing and Rehab", "Task Name": "8.24.26",
|
||||
"Assigned To": "", "Attachments": 1, "Downloaded": "Yes",
|
||||
{"Facility Name": "Balboa Nursing and Rehab", "Task Name": "10.26.26",
|
||||
"Assigned To": "B T", "Attachments": 1, "Downloaded": "Yes",
|
||||
"Reason": "Downloaded 1/1 attachment(s)"},
|
||||
{"Facility Name": "Balboa Nursing and Rehab", "Task Name": "8.21.26",
|
||||
"Assigned To": "", "Attachments": 1, "Downloaded": "Yes",
|
||||
@@ -68,18 +82,18 @@ class TestSummaryWorkbook:
|
||||
{"Facility Name": "Balboa Nursing and Rehab",
|
||||
"Task Name": "Facesheets Needed (GG)", "Assigned To": "A S",
|
||||
"Attachments": "", "Downloaded": "No",
|
||||
"Reason": "Skipped — assigned to A S"},
|
||||
"Reason": "Skipped — Facesheets Needed (GG)"},
|
||||
{"Facility Name": "Balboa Nursing and Rehab",
|
||||
"Task Name": "Facesheets Needed (GG)", "Assigned To": "D M",
|
||||
"Attachments": "", "Downloaded": "No",
|
||||
"Reason": "Skipped — assigned to D M"},
|
||||
"Reason": "Skipped — Facesheets Needed (GG)"},
|
||||
],
|
||||
}
|
||||
|
||||
def test_download_sheet_reports_assigned_skips(self, tmp_path):
|
||||
def test_download_sheet_reports_gg_skips(self, tmp_path):
|
||||
out = self._write(tmp_path, self._balboa_payload())
|
||||
df = pd.read_excel(out, sheet_name="Download")
|
||||
assert df.loc[0, "Tasks Skipped (Assigned)"] == 2
|
||||
assert df.loc[0, "Tasks Skipped (GG)"] == 2
|
||||
assert df.loc[0, "Files Downloaded"] == 2
|
||||
assert df.loc[0, "Status"] == "Success"
|
||||
|
||||
@@ -94,27 +108,27 @@ class TestSummaryWorkbook:
|
||||
facesheets = df[df["Task Name"] == "Facesheets Needed (GG)"]
|
||||
assert len(facesheets) == 2
|
||||
assert all(facesheets["Downloaded"] == "No")
|
||||
assert all("assigned to" in r for r in facesheets["Reason"])
|
||||
assert all("GG" in r for r in facesheets["Reason"])
|
||||
|
||||
def test_facility_whose_tasks_are_all_assigned(self, tmp_path):
|
||||
def test_facility_whose_tasks_are_all_gg(self, tmp_path):
|
||||
out = self._write(tmp_path, {
|
||||
"original": [],
|
||||
"tasks_total": 3,
|
||||
"tasks_with_attachments": 0,
|
||||
"tasks_with_downloads": 0,
|
||||
"tasks_skipped_no_attachment": 0,
|
||||
"tasks_skipped_assigned": 3,
|
||||
"tasks_skipped_gg": 3,
|
||||
"status_changed": 0,
|
||||
"task_rows": [],
|
||||
})
|
||||
df = pd.read_excel(out, sheet_name="Download")
|
||||
assert df.loc[0, "Status"] == "All assigned — skipped"
|
||||
assert df.loc[0, "Status"] == "All GG — skipped"
|
||||
|
||||
def test_tasks_sheet_exists_even_with_no_task_rows(self, tmp_path):
|
||||
out = self._write(tmp_path, {
|
||||
"original": [], "tasks_total": 0, "tasks_with_attachments": 0,
|
||||
"tasks_with_downloads": 0, "tasks_skipped_no_attachment": 0,
|
||||
"tasks_skipped_assigned": 0, "status_changed": 0, "task_rows": [],
|
||||
"tasks_skipped_gg": 0, "status_changed": 0, "task_rows": [],
|
||||
})
|
||||
df = pd.read_excel(out, sheet_name="Tasks")
|
||||
assert df.empty
|
||||
|
||||
Reference in new issue
Block a user