33
44from databricks .sdk import WorkspaceClient
55
6+
67def make_path_pattern (run_id : int , page_token : str ) -> str :
7- return re .compile (f'{ re .escape ("http://localhost/api/" )} 2.\d{ re .escape (f"/jobs/runs/get?page_token={ page_token } &run_id={ run_id } " )} ' )
8+ return re .compile (
9+ f'{ re .escape ("http://localhost/api/" )} 2.\d{ re .escape (f"/jobs/runs/get?page_token={ page_token } &run_id={ run_id } " )} '
10+ )
11+
812
913def test_get_run_pagination_with_tasks (config , requests_mock ):
1014 run1 = {
@@ -26,12 +30,9 @@ def test_get_run_pagination_with_tasks(config, requests_mock):
2630 "prev_page_token" : "initialToken"
2731 }
2832 run3 = {"tasks" : [{"run_id" : 4 }], "next_page_token" : None , "prev_page_token" : "tokenToSecondPage" }
29- requests_mock .get (make_path_pattern (1337 , "initialToken" ),
30- text = json .dumps (run1 ))
31- requests_mock .get (make_path_pattern (1337 , "tokenToSecondPage" ),
32- text = json .dumps (run2 ))
33- requests_mock .get (make_path_pattern (1337 , "tokenToThirdPage" ),
34- text = json .dumps (run3 ))
33+ requests_mock .get (make_path_pattern (1337 , "initialToken" ), text = json .dumps (run1 ))
34+ requests_mock .get (make_path_pattern (1337 , "tokenToSecondPage" ), text = json .dumps (run2 ))
35+ requests_mock .get (make_path_pattern (1337 , "tokenToThirdPage" ), text = json .dumps (run3 ))
3536 w = WorkspaceClient (config = config )
3637
3738 run = w .jobs .get_run (1337 , page_token = "initialToken" )
@@ -86,12 +87,9 @@ def test_get_run_pagination_with_iterations(config, requests_mock):
8687 "next_page_token" : None ,
8788 "prev_page_token" : "tokenToSecondPage"
8889 }
89- requests_mock .get (make_path_pattern (1337 , "initialToken" ),
90- text = json .dumps (run1 ))
91- requests_mock .get (make_path_pattern (1337 , "tokenToSecondPage" ),
92- text = json .dumps (run2 ))
93- requests_mock .get (make_path_pattern (1337 , "tokenToThirdPage" ),
94- text = json .dumps (run3 ))
90+ requests_mock .get (make_path_pattern (1337 , "initialToken" ), text = json .dumps (run1 ))
91+ requests_mock .get (make_path_pattern (1337 , "tokenToSecondPage" ), text = json .dumps (run2 ))
92+ requests_mock .get (make_path_pattern (1337 , "tokenToThirdPage" ), text = json .dumps (run3 ))
9593 w = WorkspaceClient (config = config )
9694
9795 run = w .jobs .get_run (1337 , page_token = "initialToken" )
0 commit comments