treeherder/tests/e2e/test_jobs_loaded.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 строки
2.3 KiB
Python
Исходник Обычный вид История

from django.urls import reverse
2013-07-18 17:47:58 +04:00
def test_pending_job_available(test_repository, pending_jobs_stored, client):
resp = client.get(reverse("jobs-list", kwargs={"project": test_repository.name}))
assert resp.status_code == 200
jobs = resp.json()
2013-07-18 17:47:58 +04:00
assert len(jobs["results"]) == 1
2013-07-18 17:47:58 +04:00
assert jobs["results"][0]["state"] == "pending"
2013-07-18 17:47:58 +04:00
def test_running_job_available(test_repository, running_jobs_stored, client):
resp = client.get(reverse("jobs-list", kwargs={"project": test_repository.name}))
assert resp.status_code == 200
jobs = resp.json()
2013-07-18 17:47:58 +04:00
assert len(jobs["results"]) == 1
2013-07-18 17:47:58 +04:00
assert jobs["results"][0]["state"] == "running"
2013-07-18 17:47:58 +04:00
def test_completed_job_available(test_repository, completed_jobs_stored, client):
resp = client.get(reverse("jobs-list", kwargs={"project": test_repository.name}))
assert resp.status_code == 200
jobs = resp.json()
2013-07-18 17:47:58 +04:00
assert len(jobs["results"]) == 1
assert jobs["results"][0]["state"] == "completed"
2013-07-23 20:39:47 +04:00
def test_pending_stored_to_running_loaded(
test_repository, pending_jobs_stored, running_jobs_stored, client
):
2013-07-23 20:39:47 +04:00
"""
tests a job transition from pending to running
given a loaded pending job, if I store and load the same job with status running,
2013-07-23 20:39:47 +04:00
the latter is shown in the jobs endpoint
"""
resp = client.get(reverse("jobs-list", kwargs={"project": test_repository.name}))
assert resp.status_code == 200
jobs = resp.json()
2013-07-23 20:39:47 +04:00
assert len(jobs["results"]) == 1
assert jobs["results"][0]["state"] == "running"
def test_finished_job_to_running(
test_repository, completed_jobs_stored, running_jobs_stored, client
):
"""
tests that a job finished cannot change state
"""
resp = client.get(reverse("jobs-list", kwargs={"project": test_repository.name}))
assert resp.status_code == 200
jobs = resp.json()
assert len(jobs["results"]) == 1
assert jobs["results"][0]["state"] == "completed"
def test_running_job_to_pending(test_repository, running_jobs_stored, pending_jobs_stored, client):
"""
tests that a job transition from pending to running
cannot happen
"""
resp = client.get(reverse("jobs-list", kwargs={"project": test_repository.name}))
assert resp.status_code == 200
jobs = resp.json()
assert len(jobs["results"]) == 1
assert jobs["results"][0]["state"] == "running"