Add spawner progress message
This commit is contained in:
parent
8574a75e37
commit
77b4c64f88
6 changed files with 186 additions and 4 deletions
34
tests/test_progress.py
Normal file
34
tests/test_progress.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
"""Test progress messages module."""
|
||||
|
||||
import pytest
|
||||
from batchspawner import JobStatus
|
||||
from glicid_spawner.progress import get_progress, jhp
|
||||
|
||||
|
||||
def test_progress_dict():
|
||||
"""Test jupyterhub progress message dictionary."""
|
||||
progress = jhp(1, 'Foo')
|
||||
|
||||
assert isinstance(progress, dict)
|
||||
assert progress['progress'] == 1
|
||||
assert progress['message'] == 'Foo'
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'job_status, elapse_time, expected',
|
||||
[
|
||||
(JobStatus.UNKNOWN, 0, 0), # ERROR
|
||||
(JobStatus.NOTFOUND, 0, 10), # SUBMIT
|
||||
(JobStatus.PENDING, 0, 20), # PENDING
|
||||
(JobStatus.RUNNING, 0, 40), # INIT
|
||||
(JobStatus.RUNNING, 10, 60), # SETUP
|
||||
(JobStatus.RUNNING, 30, 80), # CONNECT
|
||||
(JobStatus.RUNNING, 60, 95), # TOO_LONG
|
||||
],
|
||||
)
|
||||
def test_progress_msg(job_status, elapse_time, expected):
|
||||
"""Test progress getter."""
|
||||
progress = get_progress(job_status, elapse_time)
|
||||
|
||||
assert progress['progress'] == expected
|
||||
assert isinstance(progress['message'], str)
|
Loading…
Add table
Add a link
Reference in a new issue