def test_stream_ordering(self, a, b): """ Two streams are well ordered based on their stream ID. """ s1 = priority.Stream(stream_id=a, weight=16) s2 = priority.Stream(stream_id=b, weight=32) assert (s1 < s2) == (a < b) assert (s1 <= s2) == (a <= b) assert (s1 > s2) == (a > b) assert (s1 >= s2) == (a >= b) assert (s1 == s2) == (a == b) assert (s1 != s2) == (a != b)
def test_streams_are_well_ordered(self, streams_and_weights): """ Streams are ordered by their stream ID. """ stream_list = [ priority.Stream(stream_id=s, weight=w) for s, w in streams_and_weights ] stream_list = sorted(stream_list) streams_by_id = [stream.stream_id for stream in stream_list] assert sorted(streams_by_id) == streams_by_id
def test_stream_repr(self): """ The stream representation renders according to the README. """ s = priority.Stream(stream_id=80, weight=16) assert repr(s) == "Stream<id=80, weight=16>"