Skip to content

Commit a5d8706

Browse files
authored
[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
1 parent 6a9c534 commit a5d8706

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

tests/test_jobs.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
from databricks.sdk import WorkspaceClient
2+
3+
4+
# 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
5+
def test_jobs_create(config, requests_mock):
6+
requests_mock.post("http://localhost/api/2.1/jobs/create",
7+
request_headers={
8+
'Accept': 'application/json',
9+
'Content-Type': 'application/json',
10+
},
11+
text="null",
12+
)
13+
14+
w = WorkspaceClient(config=config)
15+
w.jobs.create()
16+
17+
assert requests_mock.call_count == 1
18+
assert requests_mock.called
19+
20+
21+
def test_jobs_update(config, requests_mock):
22+
requests_mock.post("http://localhost/api/2.1/jobs/update",
23+
request_headers={
24+
'Accept': 'application/json',
25+
'Content-Type': 'application/json',
26+
},
27+
text="null",
28+
)
29+
30+
w = WorkspaceClient(config=config)
31+
w.jobs.update(job_id="job_id")
32+
33+
assert requests_mock.call_count == 1
34+
assert requests_mock.called
35+
36+
37+
def test_jobs_list(config, requests_mock):
38+
requests_mock.get("http://localhost/api/2.1/jobs/list",
39+
request_headers={
40+
'Accept': 'application/json',
41+
},
42+
text="null",
43+
)
44+
45+
w = WorkspaceClient(config=config)
46+
for _ in w.jobs.list():
47+
pass
48+
49+
assert requests_mock.call_count == 1
50+
assert requests_mock.called
51+
52+
53+
def test_jobs_get(config, requests_mock):
54+
requests_mock.get("http://localhost/api/2.1/jobs/get",
55+
request_headers={
56+
'Accept': 'application/json',
57+
},
58+
text="null",
59+
)
60+
61+
w = WorkspaceClient(config=config)
62+
w.jobs.get(job_id="job_id")
63+
64+
assert requests_mock.call_count == 1
65+
assert requests_mock.called
66+
67+
68+
def test_jobs_reset(config, requests_mock):
69+
requests_mock.post("http://localhost/api/2.1/jobs/reset",
70+
request_headers={
71+
'Accept': 'application/json',
72+
'Content-Type': 'application/json',
73+
},
74+
text="null",
75+
)
76+
77+
w = WorkspaceClient(config=config)
78+
w.jobs.reset(job_id="job_id", new_settings=None)
79+
80+
assert requests_mock.call_count == 1
81+
assert requests_mock.called
82+
83+
84+
def test_jobs_runs_list(config, requests_mock):
85+
requests_mock.get("http://localhost/api/2.1/jobs/runs/list",
86+
request_headers={
87+
'Accept': 'application/json',
88+
},
89+
text="null",
90+
)
91+
92+
w = WorkspaceClient(config=config)
93+
for _ in w.jobs.list_runs(job_id="job_id"):
94+
pass
95+
96+
assert requests_mock.call_count == 1
97+
assert requests_mock.called
98+
99+
100+
# End of test cases for API 2.1 pinning

0 commit comments

Comments
 (0)