Skip to content

Commit

Permalink
add tests for different paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ekneg54 committed Feb 23, 2025
1 parent c5f1821 commit 63c6f70
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/unit/generator/http/test_batcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,20 @@ def test_batcher_shuffles_events(self):
events = [next(batcher) for _ in range(2)]
shuffled_events = [next(shuffled_batcher) for _ in range(2)]
assert events != shuffled_events

def test_batcher_handles_different_paths(self):
batches = iter(["/path/to,msg1", "/path/too,msg2", "/path/to,msg3"])
batcher = Batcher(batches, batch_size=3, events=6)
assert next(batcher) == "/path/to,msg1;msg3;msg1\n"
assert next(batcher) == "/path/too,msg2;msg2;msg2\n"
with pytest.raises(StopIteration):
next(batcher)

def test_batcher_handles_different_paths_with_shuffle(self):
batches = iter(["/path/to,msg1", "/path/too,msg2", "/path/to,msg3"])
saved_batches = copy.deepcopy(batches)
batcher = Batcher(batches, batch_size=3, events=6)
shuffled_batcher = Batcher(saved_batches, batch_size=3, events=6, shuffle=True)
events = [next(batcher) for _ in range(2)]
shuffled_events = [next(shuffled_batcher) for _ in range(2)]
assert events != shuffled_events

0 comments on commit 63c6f70

Please sign in to comment.