@@ -130,6 +130,36 @@ def test_create_job(jobs_service):
130130 jobs_service .client .perform_query .assert_called_with ('POST' , '/jobs/create' , data = {'tasks' : tasks }, headers = None , version = '2.1' )
131131
132132
133+ @provide_conf
134+ def test_create_dbt_task (jobs_service ):
135+ git_source = {
136+ 'git_provider' : 'github' ,
137+ 'git_url' : 'https://github.com/foo/bar' ,
138+ 'git_branch' : 'main'
139+ }
140+
141+ tasks = [
142+ {
143+ 'task_key' : 'dbt' ,
144+ 'dbt_task' : {
145+ 'commands' : ['dbt test' ]
146+ }
147+ }
148+ ]
149+
150+ jobs_service .create_job (git_source = git_source , tasks = tasks )
151+ jobs_service .client .perform_query .assert_called_with ('POST' , '/jobs/create' , data = {'git_source' : git_source , 'tasks' : tasks }, headers = None , version = None )
152+
153+
154+ @provide_conf
155+ def test_run_now_dbt_task (jobs_service ):
156+ job_id = 1337
157+ dbt_commands = ['dbt test' , 'dbt deps' ]
158+
159+ jobs_service .run_now (job_id = job_id , dbt_commands = dbt_commands )
160+ jobs_service .client .perform_query .assert_called_with ('POST' , '/jobs/run-now' , data = {'job_id' : job_id , 'dbt_commands' : dbt_commands }, headers = None , version = None )
161+
162+
133163@provide_conf
134164def test_create_job_invalid_types (jobs_service ):
135165 with pytest .raises (TypeError , match = 'new_cluster' ):
@@ -140,7 +170,10 @@ def test_create_job_invalid_types(jobs_service):
140170
141171 with pytest .raises (TypeError , match = 'schedule' ):
142172 jobs_service .create_job (schedule = [])
143-
173+
174+ with pytest .raises (TypeError , match = 'git_source' ):
175+ jobs_service .create_job (git_source = [])
176+
144177 with pytest .raises (TypeError , match = 'notebook_task' ):
145178 jobs_service .create_job (notebook_task = [])
146179
@@ -153,6 +186,9 @@ def test_create_job_invalid_types(jobs_service):
153186 with pytest .raises (TypeError , match = 'spark_submit_task' ):
154187 jobs_service .create_job (spark_submit_task = [])
155188
189+ with pytest .raises (TypeError , match = 'dbt_task' ):
190+ jobs_service .create_job (dbt_task = [])
191+
156192
157193@provide_conf
158194def test_submit_run_invalid_types (jobs_service ):
@@ -164,7 +200,10 @@ def test_submit_run_invalid_types(jobs_service):
164200
165201 with pytest .raises (TypeError , match = 'schedule' ):
166202 jobs_service .submit_run (schedule = [])
167-
203+
204+ with pytest .raises (TypeError , match = 'git_source' ):
205+ jobs_service .submit_run (git_source = [])
206+
168207 with pytest .raises (TypeError , match = 'notebook_task' ):
169208 jobs_service .submit_run (notebook_task = [])
170209
@@ -176,3 +215,6 @@ def test_submit_run_invalid_types(jobs_service):
176215
177216 with pytest .raises (TypeError , match = 'spark_submit_task' ):
178217 jobs_service .submit_run (spark_submit_task = [])
218+
219+ with pytest .raises (TypeError , match = 'dbt_task' ):
220+ jobs_service .submit_run (dbt_task = [])
0 commit comments