Skip to content

Commit b4189b2

Browse files
committed
Add tests that reprioritize() rejects bad weights
1 parent 40e5d3d commit b4189b2

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

test/test_priority.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,24 +398,29 @@ def test_can_insert_stream_with_exclusive_dependency_on_0(self,
398398
'priority',
399399
object
400400
])
401-
def test_insert_stream_with_non_integer_weight_is_error(self, weight):
401+
def test_stream_with_non_integer_weight_is_error(self, weight):
402402
"""
403-
Creating a stream with a non-integer weight is rejected.
403+
Giving a stream a non-integer weight is rejected.
404404
"""
405405
p = priority.PriorityTree()
406406
with pytest.raises(priority.BadWeightError) as err:
407407
p.insert_stream(stream_id=1, weight=weight)
408408
assert err.value.args[0] == 'Stream weight should be an integer'
409409

410+
p.insert_stream(stream_id=2)
411+
with pytest.raises(priority.BadWeightError) as err:
412+
p.reprioritize(stream_id=2, weight=weight)
413+
assert err.value.args[0] == 'Stream weight should be an integer'
414+
410415
@pytest.mark.parametrize('weight', [
411416
0,
412417
257,
413418
1000,
414419
-42,
415420
])
416-
def test_insert_stream_with_out_of_bounds_weight_is_error(self, weight):
421+
def test_stream_with_out_of_bounds_weight_is_error(self, weight):
417422
"""
418-
Creating a stream with an out-of-bounds integer weight is rejected.
423+
Giving a stream an out-of-bounds integer weight is rejected.
419424
"""
420425
p = priority.PriorityTree()
421426
with pytest.raises(priority.BadWeightError) as err:
@@ -424,6 +429,13 @@ def test_insert_stream_with_out_of_bounds_weight_is_error(self, weight):
424429
err.value.args[0] ==
425430
'Stream weight must be between 1 and 256 (inclusive)')
426431

432+
p.insert_stream(stream_id=2)
433+
with pytest.raises(priority.BadWeightError) as err:
434+
p.reprioritize(stream_id=2, weight=weight)
435+
assert (
436+
err.value.args[0] ==
437+
'Stream weight must be between 1 and 256 (inclusive)')
438+
427439

428440
class TestPriorityTreeOutput(object):
429441
"""

0 commit comments

Comments
 (0)