Skip to content

Commit

Permalink
Test empty sync response
Browse files Browse the repository at this point in the history
  • Loading branch information
madwort committed Oct 10, 2024
1 parent cfbb837 commit b1894b8
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from responses import matchers

from jobrunner import config, queries, sync
from jobrunner.models import JobRequest
from jobrunner.lib.database import find_where
from jobrunner.models import Job, JobRequest
from tests.factories import job_factory, metrics_factory


Expand Down Expand Up @@ -152,3 +153,24 @@ def test_session_request_flags(db, responses):

# if this works, our expected request was generated
sync.api_get("path", params={"backend": "test"})


def test_sync_empty_response(db, monkeypatch, requests_mock):
monkeypatch.setattr(
"jobrunner.config.JOB_SERVER_ENDPOINT", "http://testserver/api/v2/"
)
requests_mock.get(
"http://testserver/api/v2/job-requests/?backend=expectations",
json={
"results": [],
},
)
sync.sync()

# verify we did not post back to job-server
assert requests_mock.last_request.text is None
assert requests_mock.last_request.method == "GET"

# also that we did not create any jobs
jobs = find_where(Job)
assert jobs == []

0 comments on commit b1894b8

Please sign in to comment.