34 lines
1,014 B
Python
34 lines
1,014 B
Python
"""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)
|