-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Internal] Test that Jobs API endpoints are pinned to 2.1 (#714)
## Changes <!-- Summary of your changes that are easy to understand --> Added tests to make sure regeneration is not going to break API version pinning: databricks/databricks-sdk-go#993 ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] `make test` run locally - [x] `make fmt` applied - [ ] relevant integration tests applied
- Loading branch information
Showing
1 changed file
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
from databricks.sdk import WorkspaceClient | ||
|
||
|
||
# Test cases below are checking that we pinned API 2.1 for certain endpoints, DO NOT REMOVE OR CHANGE THEM. https://databricks.atlassian.net/browse/JOBS-19298 | ||
def test_jobs_create(config, requests_mock): | ||
requests_mock.post("http://localhost/api/2.1/jobs/create", | ||
request_headers={ | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json', | ||
}, | ||
text="null", | ||
) | ||
|
||
w = WorkspaceClient(config=config) | ||
w.jobs.create() | ||
|
||
assert requests_mock.call_count == 1 | ||
assert requests_mock.called | ||
|
||
|
||
def test_jobs_update(config, requests_mock): | ||
requests_mock.post("http://localhost/api/2.1/jobs/update", | ||
request_headers={ | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json', | ||
}, | ||
text="null", | ||
) | ||
|
||
w = WorkspaceClient(config=config) | ||
w.jobs.update(job_id="job_id") | ||
|
||
assert requests_mock.call_count == 1 | ||
assert requests_mock.called | ||
|
||
|
||
def test_jobs_list(config, requests_mock): | ||
requests_mock.get("http://localhost/api/2.1/jobs/list", | ||
request_headers={ | ||
'Accept': 'application/json', | ||
}, | ||
text="null", | ||
) | ||
|
||
w = WorkspaceClient(config=config) | ||
for _ in w.jobs.list(): | ||
pass | ||
|
||
assert requests_mock.call_count == 1 | ||
assert requests_mock.called | ||
|
||
|
||
def test_jobs_get(config, requests_mock): | ||
requests_mock.get("http://localhost/api/2.1/jobs/get", | ||
request_headers={ | ||
'Accept': 'application/json', | ||
}, | ||
text="null", | ||
) | ||
|
||
w = WorkspaceClient(config=config) | ||
w.jobs.get(job_id="job_id") | ||
|
||
assert requests_mock.call_count == 1 | ||
assert requests_mock.called | ||
|
||
|
||
def test_jobs_reset(config, requests_mock): | ||
requests_mock.post("http://localhost/api/2.1/jobs/reset", | ||
request_headers={ | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json', | ||
}, | ||
text="null", | ||
) | ||
|
||
w = WorkspaceClient(config=config) | ||
w.jobs.reset(job_id="job_id", new_settings=None) | ||
|
||
assert requests_mock.call_count == 1 | ||
assert requests_mock.called | ||
|
||
|
||
def test_jobs_runs_list(config, requests_mock): | ||
requests_mock.get("http://localhost/api/2.1/jobs/runs/list", | ||
request_headers={ | ||
'Accept': 'application/json', | ||
}, | ||
text="null", | ||
) | ||
|
||
w = WorkspaceClient(config=config) | ||
for _ in w.jobs.list_runs(job_id="job_id"): | ||
pass | ||
|
||
assert requests_mock.call_count == 1 | ||
assert requests_mock.called | ||
|
||
|
||
# End of test cases for API 2.1 pinning |