|
2 | 2 |
|
3 | 3 | import re
|
4 | 4 | from unittest import mock
|
5 |
| -from .. import BatchSpawnerRegexStates |
| 5 | +from .. import BatchSpawnerRegexStates, JobStatus |
6 | 6 | from traitlets import Unicode
|
7 | 7 | import time
|
8 | 8 | import pytest
|
@@ -135,15 +135,32 @@ def test_submit_failure(db, io_loop):
|
135 | 135 | assert spawner.job_id == ''
|
136 | 136 | assert spawner.job_status == ''
|
137 | 137 |
|
138 |
| -def test_pending_fails(db, io_loop): |
| 138 | +def test_submit_pending_fails(db, io_loop): |
| 139 | + """Submission works, but the batch query command immediately fails""" |
139 | 140 | spawner = new_spawner(db=db)
|
140 | 141 | assert spawner.get_state() == {}
|
141 | 142 | spawner.batch_query_cmd = 'echo xyz'
|
142 | 143 | with pytest.raises(RuntimeError) as e_info:
|
143 | 144 | io_loop.run_sync(spawner.start, timeout=30)
|
| 145 | + status = io_loop.run_sync(spawner.query_job_status, timeout=30) |
| 146 | + assert status == JobStatus.NOTFOUND |
144 | 147 | assert spawner.job_id == ''
|
145 | 148 | assert spawner.job_status == ''
|
146 | 149 |
|
| 150 | +def test_poll_fails(db, io_loop): |
| 151 | + """Submission works, but a later .poll() fails""" |
| 152 | + spawner = new_spawner(db=db) |
| 153 | + assert spawner.get_state() == {} |
| 154 | + # The start is successful: |
| 155 | + io_loop.run_sync(spawner.start, timeout=30) |
| 156 | + spawner.batch_query_cmd = 'echo xyz' |
| 157 | + # Now, the poll fails: |
| 158 | + io_loop.run_sync(spawner.poll, timeout=30) |
| 159 | + # .poll() will run self.clear_state() if it's not found: |
| 160 | + assert spawner.job_id == '' |
| 161 | + assert spawner.job_status == '' |
| 162 | + |
| 163 | + |
147 | 164 | def test_templates(db, io_loop):
|
148 | 165 | """Test templates in the run_command commands"""
|
149 | 166 | spawner = new_spawner(db=db)
|
|
0 commit comments