def test_rebuild_img_return_none_if_total_bytes_modulo_length_is_not_0(): # Given nb_packet = 2 total_bytes = 30 pixel_size = 3 creation = 1000 height = 10 length = 7 vt = VideoTopic(nb_packet=nb_packet, total_bytes=total_bytes, height=height, length=length, pixel_size=pixel_size, time_creation=creation) for i in range(nb_packet): vt.add_message(UDPMessage(subtopic=i + 1, payload=bytes(25 * [0]))) # When result = vt.rebuild_img() # Then assert result is None
def test_rebuild_img_return_numpy_array_as_expected_for_pixel_size_1(): # Given nb_packet = 3 total_bytes = 30 pixel_size = 1 creation = 1000 height = 10 length = 3 vt = VideoTopic(nb_packet=nb_packet, total_bytes=total_bytes, height=height, length=length, pixel_size=pixel_size, time_creation=creation) for i in range(nb_packet): vt.add_message(UDPMessage(subtopic=i + 1, payload=bytes(10 * [0]))) # When result = vt.rebuild_img() # Then assert result.shape == (height, length) assert np.array_equiv(result.flatten(), np.array(height * length * pixel_size * [0]))