def test_decode_less_than_k_data_blocks():
    k, m = 10, 4
    expected_block_size = compute_block_size(len(LITTLE_PIECE_OF_DATA), k)
    driver = PylonghairDriver(k=k, m=m)
    strips = driver.encode(LITTLE_PIECE_OF_DATA)
    decoded_data = driver.decode(strips)
    assert len(decoded_data) == len(LITTLE_PIECE_OF_DATA)
    assert decoded_data == LITTLE_PIECE_OF_DATA
def test_decode_less_than_k_data_blocks():
    k, m = 10, 4
    expected_block_size = compute_block_size(len(LITTLE_PIECE_OF_DATA), k)
    driver = PylonghairDriver(k=k, m=m)
    strips = driver.encode(LITTLE_PIECE_OF_DATA)
    decoded_data = driver.decode(strips)
    assert len(decoded_data) == len(LITTLE_PIECE_OF_DATA)
    assert decoded_data == LITTLE_PIECE_OF_DATA
def test_decode():
    k, m = 10, 4
    expected_block_size = compute_block_size(len(DATA), k)
    driver = PylonghairDriver(k=k, m=m)
    strips = driver.encode(DATA)
    decoded_data = driver.decode(strips)
    assert len(decoded_data) == len(DATA)
    assert decoded_data == DATA
def test_decode():
    k, m = 10, 4
    expected_block_size = compute_block_size(len(DATA), k)
    driver = PylonghairDriver(k=k, m=m)
    strips = driver.encode(DATA)
    decoded_data = driver.decode(strips)
    assert len(decoded_data) == len(DATA)
    assert decoded_data == DATA
def test_encode_less_than_k_data_blocks():
    k, m = 10, 4
    expected_block_size = compute_block_size(len(LITTLE_PIECE_OF_DATA), k)
    driver = PylonghairDriver(k=k, m=m)
    strips = driver.encode(LITTLE_PIECE_OF_DATA)
    assert isinstance(strips, list)
    assert len(strips) == 13
    # Test parity blocks have expected block size
    expected_parity_strips = strips[len(strips) - m:]
    assert m == len(expected_parity_strips)
    for strip in expected_parity_strips:
        assert expected_block_size == len(strip)
def test_encode():
    k, m = 10, 4
    expected_block_size = compute_block_size(len(DATA), k)
    driver = PylonghairDriver(k=k, m=m)
    strips = driver.encode(DATA)
    assert isinstance(strips, list)
    assert len(strips) == 14
    # Test parity blocks have expected block size
    expected_parity_strips = strips[len(strips) - m:]
    assert m == len(expected_parity_strips)
    for strip in expected_parity_strips:
        assert expected_block_size == len(strip)
def test_encode():
    k, m = 10, 4
    expected_block_size = compute_block_size(len(DATA), k)
    driver = PylonghairDriver(k=k, m=m)
    strips = driver.encode(DATA)
    assert isinstance(strips, list)
    assert len(strips) == 14
    # Test parity blocks have expected block size
    expected_parity_strips = strips[len(strips) - m:]
    assert m == len(expected_parity_strips)
    for strip in expected_parity_strips:
        assert expected_block_size == len(strip)
def test_encode_less_than_k_data_blocks():
    k, m = 10, 4
    expected_block_size = compute_block_size(len(LITTLE_PIECE_OF_DATA), k)
    driver = PylonghairDriver(k=k, m=m)
    strips = driver.encode(LITTLE_PIECE_OF_DATA)
    assert isinstance(strips, list)
    assert len(strips) == 13
    # Test parity blocks have expected block size
    expected_parity_strips = strips[len(strips) - m:]
    assert m == len(expected_parity_strips)
    for strip in expected_parity_strips:
        assert expected_block_size == len(strip)
def test_compute_block_size_returns_a_multiple_of_8_if_initial_block_size_is_higher_than_8():
    block_size = compute_block_size(1024, 10)
    assert block_size == 104
def test_compute_block_size_returns_8_if_block_size_is_lower_than_8():
    block_size = compute_block_size(8, 3)
    assert block_size == 8
def test_compute_block_size_throws_error_if_k_is_lower_than_zero():
    with pytest.raises(AssertionError):
        compute_block_size(8, -1)
def test_compute_block_size_throws_error_if_k_equals_zero():
    with pytest.raises(AssertionError):
        compute_block_size(8, 0)
def test_compute_block_size_returns_a_multiple_of_8_if_initial_block_size_is_higher_than_8(
):
    block_size = compute_block_size(1024, 10)
    assert block_size == 104
def test_compute_block_size_returns_8_if_block_size_is_lower_than_8():
    block_size = compute_block_size(8, 3)
    assert block_size == 8
def test_compute_block_size_throws_error_if_k_is_lower_than_zero():
    with pytest.raises(AssertionError):
        compute_block_size(8, -1)
def test_compute_block_size_throws_error_if_k_equals_zero():
    with pytest.raises(AssertionError):
        compute_block_size(8, 0)