@@ -66,7 +66,7 @@ def dataflow_job_name(request):
66
66
67
67
# cancel the Dataflow job after running the test
68
68
# no need to cancel after the empty_args test - it won't create a job and cancellation will throw an error
69
- if label != "test_run_template_empty " :
69
+ if label != "test-run-template-empty " :
70
70
dataflow_jobs_cancel (job_name )
71
71
else :
72
72
print ("No active jobs to cancel, cancelling skipped." )
@@ -86,12 +86,15 @@ def get_job_id_from_name(job_name):
86
86
)
87
87
response = jobs_request .execute ()
88
88
89
- # search for the job in the list that has our name (names are unique)
90
- for job in response ["jobs" ]:
91
- if job ["name" ] == job_name :
92
- return job ["id" ]
93
- # if we don't find a job, just return
94
- return
89
+ try :
90
+ # search for the job in the list that has our name (names are unique)
91
+ for job in response ["jobs" ]:
92
+ if job ["name" ] == job_name :
93
+ return job ["id" ]
94
+ # if we don't find a job, just return
95
+ return
96
+ except Exception as e :
97
+ raise ValueError (f"response:\n { response } " ) from e
95
98
96
99
97
100
# We retry the cancel operation a few times until the job is in a state where it can be cancelled
@@ -115,7 +118,7 @@ def dataflow_jobs_cancel(job_name):
115
118
116
119
117
120
@pytest .mark .parametrize (
118
- "dataflow_job_name" , [("test_run_template_empty " )], indirect = True
121
+ "dataflow_job_name" , [("test-run-template-empty " )], indirect = True
119
122
)
120
123
def test_run_template_python_empty_args (app , dataflow_job_name ):
121
124
project = PROJECT
@@ -125,7 +128,7 @@ def test_run_template_python_empty_args(app, dataflow_job_name):
125
128
126
129
127
130
@pytest .mark .parametrize (
128
- "dataflow_job_name" , [("test_run_template_python " )], indirect = True
131
+ "dataflow_job_name" , [("test-run-template-python " )], indirect = True
129
132
)
130
133
def test_run_template_python (app , dataflow_job_name ):
131
134
project = PROJECT
@@ -135,7 +138,7 @@ def test_run_template_python(app, dataflow_job_name):
135
138
"output" : "gs://{}/dataflow/wordcount/outputs" .format (BUCKET ),
136
139
}
137
140
res = main .run (project , dataflow_job_name , template , parameters )
138
- assert "test_run_template_python" in res ["job" ]["name" ]
141
+ assert dataflow_job_name in res ["job" ]["name" ]
139
142
140
143
141
144
def test_run_template_http_empty_args (app ):
@@ -145,7 +148,7 @@ def test_run_template_http_empty_args(app):
145
148
146
149
147
150
@pytest .mark .parametrize (
148
- "dataflow_job_name" , [("test_run_template_url " )], indirect = True
151
+ "dataflow_job_name" , [("test-run-template-url " )], indirect = True
149
152
)
150
153
def test_run_template_http_url (app , dataflow_job_name ):
151
154
args = {
@@ -158,11 +161,11 @@ def test_run_template_http_url(app, dataflow_job_name):
158
161
with app .test_request_context ("/?" + url_encode (args )):
159
162
res = main .run_template (flask .request )
160
163
data = json .loads (res )
161
- assert "test_run_template_url" in data ["job" ]["name" ]
164
+ assert dataflow_job_name in data ["job" ]["name" ]
162
165
163
166
164
167
@pytest .mark .parametrize (
165
- "dataflow_job_name" , [("test_run_template_data " )], indirect = True
168
+ "dataflow_job_name" , [("test-run-template-data " )], indirect = True
166
169
)
167
170
def test_run_template_http_data (app , dataflow_job_name ):
168
171
args = {
@@ -175,11 +178,11 @@ def test_run_template_http_data(app, dataflow_job_name):
175
178
with app .test_request_context (data = args ):
176
179
res = main .run_template (flask .request )
177
180
data = json .loads (res )
178
- assert "test_run_template_data" in data ["job" ]["name" ]
181
+ assert dataflow_job_name in data ["job" ]["name" ]
179
182
180
183
181
184
@pytest .mark .parametrize (
182
- "dataflow_job_name" , [("test_run_template_json " )], indirect = True
185
+ "dataflow_job_name" , [("test-run-template-json " )], indirect = True
183
186
)
184
187
def test_run_template_http_json (app , dataflow_job_name ):
185
188
args = {
@@ -192,4 +195,4 @@ def test_run_template_http_json(app, dataflow_job_name):
192
195
with app .test_request_context (json = args ):
193
196
res = main .run_template (flask .request )
194
197
data = json .loads (res )
195
- assert "test_run_template_json" in data ["job" ]["name" ]
198
+ assert dataflow_job_name in data ["job" ]["name" ]
0 commit comments