def test_events_reader_invalid_data(): data, _ = _get_test_data() data1 = bytearray(data) data1[0] = (data1[0] + 1) % 256 reader = EventsFileReader(BytesIO(data1)) with pytest.raises(EventReadingException): list(reader) data2 = bytearray(data) data2[123] = (data2[123] + 1) % 256 reader = EventsFileReader(BytesIO(data2)) with pytest.raises(EventReadingException): list(reader)
def test_events_reader_invalid_data(): """@TODO: Docs. Contribution is welcome.""" data, _ = _get_test_data() data1 = bytearray(data) data1[0] = (data1[0] + 1) % 256 reader = EventsFileReader(BytesIO(data1)) with pytest.raises(EventReadingException): list(reader) data2 = bytearray(data) data2[123] = (data2[123] + 1) % 256 reader = EventsFileReader(BytesIO(data2)) with pytest.raises(EventReadingException): list(reader)
def test_events_reader_unexpected_end(): """@TODO: Docs. Contribution is welcome.""" data, _ = _get_test_data() data = data[:-5] reader = EventsFileReader(BytesIO(data)) with pytest.raises(EventReadingException): list(reader)
def test_events_reader_successful(): data, data_raw = _get_test_data() reader = EventsFileReader(BytesIO(data)) for event, event_raw in zip(reader, data_raw): if event_raw is not None: assert event.step == event_raw["step"] assert event.HasField("summary") assert len(event.summary.value) == 1 if event_raw["type"] == "scalar": assert event.summary.value[0].HasField("simple_value") assert event.summary.value[0].tag == event_raw["tag"] assert event.summary.value[0].simple_value == event_raw[ "value"] elif event_raw["type"] == "image": assert event.summary.value[0].HasField("image") assert event.summary.value[0].image.height == 2 assert event.summary.value[0].image.width == 2 assert event.summary.value[0].image.colorspace == 3 _compare_image_data( event.summary.value[0].image.encoded_image_string, event_raw["value"])
def test_events_reader_unexpected_end(): data, _ = _get_test_data() data = data[:-5] reader = EventsFileReader(BytesIO(data)) with pytest.raises(EventReadingException): list(reader)
def test_events_reader_empty(): data = BytesIO(b"") reader = EventsFileReader(data) assert len(list(reader)) == 0
def test_events_reader_empty(): """@TODO: Docs. Contribution is welcome.""" data = BytesIO(b"") reader = EventsFileReader(data) assert len(list(reader)) == 0