@@ -254,7 +254,7 @@ async def test_get_job_types(
254254) -> None :
255255 unique_job_type = {item .type for item in job_types }
256256 response = await test_client .get (
257- "/v1/jobs/job_types " ,
257+ "/v1/jobs/job-types " ,
258258 headers = {"Authorization" : f"Bearer { mocked_user .access_token } " },
259259 )
260260
@@ -265,47 +265,21 @@ async def test_get_job_types(
265265async def test_search_jobs_by_location_id (
266266 test_client : AsyncClient ,
267267 async_session : AsyncSession ,
268- jobs_search_with_different_locations : tuple [Job ],
268+ jobs_with_locations_and_types : tuple [Job ],
269269 mocked_user : MockedUser ,
270270) -> None :
271- jobs = await enrich_jobs (jobs_search_with_different_locations , async_session )
272- response = await test_client .get (
273- "/v1/jobs" ,
274- headers = {"Authorization" : f"Bearer { mocked_user .access_token } " },
275- params = {"search_query" : "my-job" },
276- )
277-
278- assert response .status_code == HTTPStatus .OK , response .json ()
279- assert response .json () == {
280- "meta" : {
281- "has_next" : False ,
282- "has_previous" : False ,
283- "next_page" : None ,
284- "page" : 1 ,
285- "page_size" : 20 ,
286- "pages_count" : 1 ,
287- "previous_page" : None ,
288- "total_count" : 3 ,
289- },
290- "items" : [
291- {
292- "id" : str (job .id ),
293- "data" : job_to_json (job ),
294- }
295- for job in jobs
296- ],
297- }
271+ jobs = await enrich_jobs (jobs_with_locations_and_types , async_session )
298272
299273 # first job in jobs has a different location unlike two others
300274 [_ , dag_job , task_job ] = jobs
301- response_with_location_id_filter = await test_client .get (
275+ response = await test_client .get (
302276 "/v1/jobs" ,
303277 headers = {"Authorization" : f"Bearer { mocked_user .access_token } " },
304- params = {"search_query" : "my-job" , " location_id" : dag_job .location_id },
278+ params = {"location_id" : dag_job .location_id },
305279 )
306280
307- assert response_with_location_id_filter .status_code == HTTPStatus .OK , response_with_location_id_filter .json ()
308- assert response_with_location_id_filter .json () == {
281+ assert response .status_code == HTTPStatus .OK , response .json ()
282+ assert response .json () == {
309283 "meta" : {
310284 "has_next" : False ,
311285 "has_previous" : False ,
@@ -329,17 +303,17 @@ async def test_search_jobs_by_location_id(
329303async def test_search_jobs_by_location_id_non_existen_id (
330304 test_client : AsyncClient ,
331305 async_session : AsyncSession ,
332- jobs_search_with_different_locations : tuple [Job ],
306+ jobs_with_locations_and_types : tuple [Job ],
333307 mocked_user : MockedUser ,
334308):
335- response_with_location_id_filter = await test_client .get (
309+ response = await test_client .get (
336310 "/v1/jobs" ,
337311 headers = {"Authorization" : f"Bearer { mocked_user .access_token } " },
338- params = {"search_query" : "my-job" , " location_id" : - 1 },
312+ params = {"location_id" : - 1 },
339313 )
340314
341- assert response_with_location_id_filter .status_code == HTTPStatus .OK , response_with_location_id_filter .json ()
342- assert response_with_location_id_filter .json () == {
315+ assert response .status_code == HTTPStatus .OK , response .json ()
316+ assert response .json () == {
343317 "meta" : {
344318 "has_next" : False ,
345319 "has_previous" : False ,
@@ -354,18 +328,18 @@ async def test_search_jobs_by_location_id_non_existen_id(
354328 }
355329
356330
357- async def test_search_jobs_by_name_and_type (
331+ async def test_search_by_jobs_type (
358332 test_client : AsyncClient ,
359333 async_session : AsyncSession ,
360- jobs_search_with_different_types : tuple [Job ],
334+ jobs_with_locations_and_types : tuple [Job ],
361335 mocked_user : MockedUser ,
362336) -> None :
363- jobs = await enrich_jobs (jobs_search_with_different_types , async_session )
364- job_with_dag_type = jobs [ 0 ]
337+ jobs = await enrich_jobs (jobs_with_locations_and_types , async_session )
338+ [ _ , dag_job , task_job ] = jobs
365339 response = await test_client .get (
366340 "/v1/jobs" ,
367341 headers = {"Authorization" : f"Bearer { mocked_user .access_token } " },
368- params = {"search_query " : "airflow" },
342+ params = {"job_type " : [ "AIRFLOW_DAG" , "AIRFLOW_TASK" ] },
369343 )
370344
371345 assert response .status_code == HTTPStatus .OK , response .json ()
@@ -385,51 +359,25 @@ async def test_search_jobs_by_name_and_type(
385359 "id" : str (job .id ),
386360 "data" : job_to_json (job ),
387361 }
388- for job in jobs
362+ for job in ( dag_job , task_job )
389363 ],
390364 }
391365
392- response_with_type_filter = await test_client .get (
393- "/v1/jobs" ,
394- headers = {"Authorization" : f"Bearer { mocked_user .access_token } " },
395- params = {"job_type" : "AIRFLOW_DAG" , "search_query" : "airflow" },
396- )
397366
398- assert response_with_type_filter .status_code == HTTPStatus .OK , response_with_type_filter .json ()
399- assert response_with_type_filter .json () == {
400- "meta" : {
401- "has_next" : False ,
402- "has_previous" : False ,
403- "next_page" : None ,
404- "page" : 1 ,
405- "page_size" : 20 ,
406- "pages_count" : 1 ,
407- "previous_page" : None ,
408- "total_count" : 1 ,
409- },
410- "items" : [
411- {
412- "id" : str (job_with_dag_type .id ),
413- "data" : job_to_json (job_with_dag_type ),
414- },
415- ],
416- }
417-
418-
419- async def test_search_jobs_by_name_and_type_non_existen_type (
367+ async def test_search_jobs_by_non_existen_type (
420368 test_client : AsyncClient ,
421369 async_session : AsyncSession ,
422- jobs_search_with_different_types : tuple [Job ],
370+ jobs_with_locations_and_types : tuple [Job ],
423371 mocked_user : MockedUser ,
424372) -> None :
425- response_with_type_filter = await test_client .get (
373+ response = await test_client .get (
426374 "/v1/jobs" ,
427375 headers = {"Authorization" : f"Bearer { mocked_user .access_token } " },
428- params = {"job_type" : "NO_EXISTEN_TYPE" , "search_query" : "airflow" },
376+ params = {"job_type" : "NO_EXISTEN_TYPE" },
429377 )
430378
431- assert response_with_type_filter .status_code == HTTPStatus .OK , response_with_type_filter .json ()
432- assert response_with_type_filter .json () == {
379+ assert response .status_code == HTTPStatus .OK , response .json ()
380+ assert response .json () == {
433381 "meta" : {
434382 "has_next" : False ,
435383 "has_previous" : False ,
0 commit comments