Put the since-when suffix in since, so its own test covers it
This commit is contained in:
@@ -10,9 +10,9 @@ from failure import Failure
|
||||
|
||||
|
||||
def since(folder: pathlib.Path, chunk: Parked) -> str:
|
||||
"""When the chunk parked on what its file says it awaits, to the minute in the machine's time zone: the file is written once per gate, so its time is when the gate began. Empty where the file cannot be read."""
|
||||
"""`, since <time>`, the time the chunk parked on what its file says it awaits, to the minute in the machine's time zone: the file is written once per gate, so its time is when the gate began. Empty where the file cannot be read."""
|
||||
try:
|
||||
return datetime.datetime.fromtimestamp(file_of(folder, chunk.issue).stat().st_mtime).strftime("%Y-%m-%d %H:%M")
|
||||
return f", since {datetime.datetime.fromtimestamp(file_of(folder, chunk.issue).stat().st_mtime).strftime('%Y-%m-%d %H:%M')}"
|
||||
except OSError:
|
||||
return ""
|
||||
|
||||
@@ -31,8 +31,7 @@ def lines(key: str, home: pathlib.Path, issues: list[EpicIssue], run: tmux.Tmux)
|
||||
reasons = {wait.issue: wait.reason for wait in waits}
|
||||
for chunk in found:
|
||||
if chunk.issue in parked:
|
||||
gate = since(folder, parked[chunk.issue])
|
||||
when = f", since {gate}" if gate else ""
|
||||
when = since(folder, parked[chunk.issue])
|
||||
reasons[chunk.issue] = parked[chunk.issue].waits(live[chunk.issue].awaits) + when if chunk.issue in live else f"{parked[chunk.issue].waits('')}{when}, and its window stopped; {again}"
|
||||
elif chunk.issue not in live:
|
||||
reasons[chunk.issue] = f"its window stopped; {again}" if chunk.issue in {window.name for window in windows} else f"it has not started; `do-epic {key}` starts it once the epic and its repo have room"
|
||||
|
||||
@@ -55,6 +55,13 @@ class TheStatusLines(unittest.TestCase):
|
||||
|
||||
|
||||
class TheTimeSinceParking(unittest.TestCase):
|
||||
def test_is_the_time_of_the_chunks_file_to_the_minute(self) -> None:
|
||||
folder = pathlib.Path(tempfile.mkdtemp())
|
||||
chunk = parked.Parked("ABC-20", "/code/api", "7", "s", "an approval")
|
||||
parked.park(folder, chunk)
|
||||
os.utime(parked.file_of(folder, "ABC-20"), (SINCE, SINCE))
|
||||
self.assertEqual(status.since(folder, chunk), f", since {SINCE_ON}")
|
||||
|
||||
def test_is_empty_where_the_chunks_file_is_gone(self) -> None:
|
||||
self.assertEqual(status.since(pathlib.Path(tempfile.mkdtemp()), parked.Parked("ABC-20", "/code/api", "7", "s", "an approval")), "")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user