Skip to content

Commit 6900f79

Browse files
authored
Merge pull request #129 from ooni/fix-range
Fix the build_timestamps function for ranges starting at midnight
2 parents a58b3d0 + 8d86db4 commit 6900f79

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

oonipipeline/src/oonipipeline/cli/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def build_timestamps(
3030
while current < end_at:
3131
if (
3232
current.hour == 0
33-
and current != start_at
3433
and current < end_at.replace(hour=0)
3534
):
3635
timestamps.append((current.strftime("%Y-%m-%d"), current))

oonipipeline/tests/test_cli.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ def test_build_timestamps_long():
9696
map(lambda x: x[0], result)
9797
) # Complete day in the middle
9898

99+
def test_build_timestamps_long_2():
100+
start = datetime.strptime("2024-01-01", "%Y-%m-%d")
101+
end = datetime.strptime("2024-02-01", "%Y-%m-%d")
102+
result = build_timestamps(start, end)
103+
104+
assert result[0][0] == "2024-01-01" # First day
105+
assert result[-1][0] == "2024-01-31" # Last day
106+
assert len(result) == 31
99107

100108
def test_build_timestamps_single_day():
101109
start = datetime.strptime("2024-01-01 01", "%Y-%m-%d %H")
@@ -111,7 +119,7 @@ def test_build_timestamps_midnight():
111119
end = datetime.strptime("2024-01-03 00", "%Y-%m-%d %H")
112120
result = build_timestamps(start, end)
113121

114-
assert result[0][0] == "2024-01-01T00"
122+
assert result[0][0] == "2024-01-01"
115123
assert "2024-01-02" in list(map(lambda x: x[0], result))
116124
assert result[-1][0] == "2024-01-02"
117125

0 commit comments

Comments
 (0)