Skip to content

Commit

Permalink
Merge pull request #874 from dcs4cop/pont-xxx-fix-cancel-job-test
Browse files Browse the repository at this point in the history
Fix ComputeJobsRoutesTest.test_cancel_job
  • Loading branch information
pont-us committed Aug 3, 2023
2 parents a0cc15d + c8c3901 commit 4dc6f52
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/webapi/compute/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

import time
import xarray as xr
from xcube.webapi.compute.op.decorator import operation

from ..helpers import RoutesTestCase

Expand Down Expand Up @@ -150,18 +153,21 @@ def test_cancel_nonexistent_job(self):
self.assertEqual(404, status)

def test_cancel_job(self):
@operation
def slow_identity(dataset: xr.Dataset) -> xr.Dataset:
time.sleep(10) # Ensure the job runs long enough to be cancelled
return dataset

job1, status1 = self.fetch_json(
'/compute/jobs',
method="PUT",
body={
"operationId": "spatial_subset",
"operationId": "slow_identity",
"parameters": {
"dataset": "demo",
"bbox": [1, 51, 4, 52]
},
"output": {
"datasetId": "demo_subset",
"title": "My demo subset"
"datasetId": "demo2",
}
}
)
Expand All @@ -172,7 +178,6 @@ def test_cancel_job(self):
self.assertEqual(job2['state']['status'], 'cancelled')

def test_mldataset(self):
from xcube.webapi.compute.op.decorator import operation
from xcube.core.mldataset import MultiLevelDataset

@operation
Expand Down

0 comments on commit 4dc6f52

Please sign in to comment.