@@ -231,7 +231,7 @@ def test_find_ready_extracts_by_filename_partial_not_descending(self):
231231
232232 self .assertNotEqual (expected_result , given_result )
233233
234- def test_find_ready_extracts_by_location (self ):
234+ def test_find_ready_extracts_by_location_name (self ):
235235 """
236236 Testing that for the given location name, find the extracts, provided they are in 'ready' state. Should return
237237 them in ascending order by registration datettime.
@@ -266,7 +266,7 @@ def test_find_ready_extracts_by_location(self):
266266 ]
267267
268268 given_result = self .process_tracker .find_ready_extracts_by_location (
269- "Test Location"
269+ location_name = "Test Location"
270270 )
271271 given_result = [record .full_filepath () for record in given_result ]
272272
@@ -307,12 +307,67 @@ def test_find_ready_extracts_by_location_not_descending(self):
307307 ]
308308
309309 given_result = self .process_tracker .find_ready_extracts_by_location (
310- "Test Location"
310+ location_name = "Test Location"
311311 )
312312 given_result = [record .full_filepath () for record in given_result ]
313313
314314 self .assertNotEqual (expected_result , given_result )
315315
316+ def test_find_ready_extracts_by_location_path (self ):
317+ """
318+ Testing that for the given location path, find the extracts, provided they are in 'ready' state. Should return
319+ them in ascending order by registration datettime.
320+ :return:
321+ """
322+ extract = ExtractTracker (
323+ process_run = self .process_tracker ,
324+ filename = "test_extract_filename4-1.csv" ,
325+ location_name = "Test Location" ,
326+ location_path = "/home/test/extract_dir" ,
327+ )
328+
329+ extract2 = ExtractTracker (
330+ process_run = self .process_tracker ,
331+ filename = "test_extract_filename4-2.csv" ,
332+ location_name = "Test Location" ,
333+ location_path = "/home/test/extract_dir" ,
334+ )
335+
336+ # Need to manually change the status, because this would normally be done while the process was processing data
337+ extract .extract .extract_status_id = extract .extract_status_ready
338+ session = Session .object_session (extract .extract )
339+ session .commit ()
340+
341+ extract2 .extract .extract_status_id = extract2 .extract_status_ready
342+ session = Session .object_session (extract2 .extract )
343+ session .commit ()
344+
345+ expected_result = [
346+ "/home/test/extract_dir/test_extract_filename4-1.csv" ,
347+ "/home/test/extract_dir/test_extract_filename4-2.csv" ,
348+ ]
349+
350+ given_result = self .process_tracker .find_ready_extracts_by_location (
351+ location_path = "/home/test/extract_dir"
352+ )
353+ given_result = [record .full_filepath () for record in given_result ]
354+
355+ self .assertCountEqual (expected_result , given_result )
356+
357+ def test_find_ready_extracts_by_location_unset (self ):
358+ """
359+ Testing that if both the location path and location name are not set, find_ready_extracts_by_location
360+ will throw an exception.
361+ :return:
362+ """
363+ with self .assertRaises (Exception ) as context :
364+ self .process_tracker .find_ready_extracts_by_location ()
365+
366+ return self .assertTrue (
367+ "A location name or path must be provided. Please try again."
368+ in str (context .exception )
369+ )
370+
316371 def test_find_ready_extracts_by_process (self ):
317372 """
318373 Testing that for the given process name, find the extracts, provided they are in 'ready' state.
0 commit comments