indexing lister: Force bounds of integer ranges to be integers
This commit is contained in:
parent
1e7a905a13
commit
2c5528ef59
2 changed files with 20 additions and 0 deletions
|
@ -130,6 +130,9 @@ class IndexingLister(ListerBase):
|
|||
return bound.isoformat()
|
||||
min_index = dateutil.parser.parse(min_index)
|
||||
max_index = dateutil.parser.parse(max_index)
|
||||
elif isinstance(max_index - min_index, int):
|
||||
def format_bound(bound):
|
||||
return int(bound)
|
||||
else:
|
||||
def format_bound(bound):
|
||||
return bound
|
||||
|
|
|
@ -103,3 +103,20 @@ def test_db_partition_indices_float_index_range():
|
|||
expected_bounds[0] = expected_bounds[-1] = None
|
||||
|
||||
assert partitions == list(zip(expected_bounds[:-1], expected_bounds[1:]))
|
||||
|
||||
|
||||
def test_db_partition_indices_uneven_int_index_range():
|
||||
m = MockedIndexingListerDbPartitionIndices(
|
||||
num_entries=5641,
|
||||
first_index=0,
|
||||
last_index=10000,
|
||||
)
|
||||
assert m
|
||||
|
||||
partitions = m.db_partition_indices(500)
|
||||
|
||||
assert len(partitions) == 5641 // 500
|
||||
|
||||
for i, (start, end) in enumerate(partitions):
|
||||
assert isinstance(start, int) or (i == 0 and start is None)
|
||||
assert isinstance(end, int) or (i == 10 and end is None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue