diff --git a/swh/lister/core/indexing_lister.py b/swh/lister/core/indexing_lister.py --- a/swh/lister/core/indexing_lister.py +++ b/swh/lister/core/indexing_lister.py @@ -121,7 +121,7 @@ min_index = self.db_first_index() max_index = self.db_last_index() - if not min_index or not max_index: + if min_index is None or max_index is None: # Nothing to list return [] diff --git a/swh/lister/core/tests/test_indexing_lister.py b/swh/lister/core/tests/test_indexing_lister.py --- a/swh/lister/core/tests/test_indexing_lister.py +++ b/swh/lister/core/tests/test_indexing_lister.py @@ -47,6 +47,22 @@ assert partitions[-1] == (9001, None) +def test_db_partition_indices_zero_first(): + m = MockedIndexingListerDbPartitionIndices( + num_entries=1000, + first_index=0, + last_index=10000, + ) + assert m + + partitions = m.db_partition_indices(100) + + # 1000 entries with indices 0 - 10000, partitions of 100 entries + assert len(partitions) == 10 + assert partitions[0] == (None, 1000) + assert partitions[-1] == (9000, None) + + def test_db_partition_indices_date_indices(): # 24 hour delta first = datetime.datetime.fromisoformat('2019-11-01T00:00:00+00:00') @@ -74,8 +90,8 @@ def test_db_partition_indices_float_index_range(): m = MockedIndexingListerDbPartitionIndices( num_entries=10000, - first_index=1.0, - last_index=2.0, + first_index=0.0, + last_index=1.0, ) assert m @@ -83,7 +99,7 @@ assert len(partitions) == 10 - expected_bounds = [1.0 + 0.1 * i for i in range(11)] + expected_bounds = [0.1 * i for i in range(11)] expected_bounds[0] = expected_bounds[-1] = None assert partitions == list(zip(expected_bounds[:-1], expected_bounds[1:]))