Skip to content

Commit

Permalink
Fix off-by-one error in send_on with all files
Browse files Browse the repository at this point in the history
  • Loading branch information
BenGalewsky committed Jul 15, 2024
1 parent d9553c7 commit 415c772
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/servicex_did_finder_lib/accumulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ def send_on(self, count):

# Sort the list to insure reproducibility
files = sorted(self.file_cache, key=lambda x: x["paths"])
self.send_bulk(files[:count])
if count == -1:
self.send_bulk(files)
else:
self.send_bulk(files[:count])

self.file_cache.clear()

def send_bulk(self, file_list: List[Dict[str, Any]]):
Expand Down
11 changes: 11 additions & 0 deletions tests/servicex_did_finder_lib_tests/test_accumulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ def test_send_on(servicex, did_summary_obj, single_file_info):
assert acc.summary.file_count == 3


def test_send_on_all_files(servicex, did_summary_obj, single_file_info):
acc = Accumulator(sx=servicex, sum=did_summary_obj)
acc.add([single_file_info, single_file_info, single_file_info])
acc.send_on(-1)
servicex.put_file_add_bulk.assert_called_with(
[single_file_info, single_file_info, single_file_info]
)
assert acc.cache_len == 0
assert acc.summary.file_count == 3


def test_invalid_constructor_arg(servicex, did_summary_obj):
with pytest.raises(ValueError):
acc = Accumulator(sx=servicex, sum=did_summary_obj)
Expand Down

0 comments on commit 415c772

Please sign in to comment.