Skip to content

Commit e1f8c05

Browse files
fix tests
1 parent 802bf54 commit e1f8c05

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

core/pioreactor/actions/self_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from pioreactor.pubsub import Client
3939
from pioreactor.pubsub import post_into_leader
4040
from pioreactor.pubsub import prune_retained_messages
41+
from pioreactor.states import JobState
4142
from pioreactor.types import LedChannel
4243
from pioreactor.types import PdChannel
4344
from pioreactor.utils import is_pio_job_running
@@ -91,9 +92,9 @@ def test_REF_is_in_correct_position(managed_state, logger: CustomLogger, unit: s
9192
signals[channel].append(reading.ods[channel].od)
9293

9394
if i % 5 == 0 and i % 2 == 0:
94-
st.set_state("ready")
95+
st.set_state(JobState.READY)
9596
elif i % 5 == 0:
96-
st.set_state("sleeping")
97+
st.set_state(JobState.SLEEPING)
9798

9899
if i == 25:
99100
break

core/pioreactor/cli/pio.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,11 @@ def job_history() -> None:
384384
click.echo(_format_job_history_line(*job))
385385

386386

387-
def _format_timestamp_to_seconds(timestamp: str) -> str:
388-
"""
389-
Truncate timestamps like 2024-01-01T00:00:00.123456Z to second precision.
390-
"""
387+
def _format_timestamp_to_seconds(timestamp: str | None) -> str:
388+
389+
if timestamp is None:
390+
return ""
391+
391392
try:
392393
dt = to_datetime(timestamp)
393394
except ValueError:
@@ -451,7 +452,7 @@ def job_info(job_id: int | None, job_name: str | None) -> None:
451452
for setting, value, created_at, updated_at in settings:
452453
setting_label = click.style(setting, fg="cyan")
453454
created_at_display = _format_timestamp_to_seconds(created_at)
454-
updated_at_display = _format_timestamp_to_seconds(updated_at) if updated_at is not None else ""
455+
updated_at_display = _format_timestamp_to_seconds(updated_at)
455456

456457
def _stringify(val: Any) -> str:
457458
if val is None:

core/tests/test_cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_list_plugins() -> None:
6161
assert "my-example-plugin==0.2.0" in result.output
6262

6363

64-
@pytest.mark.skip(reason="not sure why this fails")
64+
@pytest.mark.flakey
6565
def test_pio_log() -> None:
6666
with collect_all_logs_of_level("DEBUG", whoami.get_unit_name(), whoami.UNIVERSAL_EXPERIMENT) as bucket:
6767
runner = CliRunner()
@@ -192,9 +192,9 @@ def test_pio_job_info_lists_job() -> None:
192192
jm.set_not_running(job_id)
193193

194194

195-
def test_pio_job_history_lists_job() -> None:
195+
def test_pio_job_list_lists_job() -> None:
196196
runner = CliRunner()
197-
job_name = "test_job_history"
197+
job_name = "test_job_list"
198198
unit = whoami.get_unit_name()
199199
experiment = whoami.UNIVERSAL_EXPERIMENT
200200

@@ -210,7 +210,7 @@ def test_pio_job_history_lists_job() -> None:
210210
)
211211
jm.set_not_running(job_id)
212212

213-
result = runner.invoke(pio, ["jobs", "history"])
213+
result = runner.invoke(pio, ["jobs", "list"])
214214

215215
assert result.exit_code == 0
216216
matching_lines = [line for line in result.output.splitlines() if f"[job_id={job_id}]" in line]

0 commit comments

Comments
 (0)