import os
from io import StringIO
import pytest
import las_rs
test_dir = os.path.dirname(__file__)
def fixture(*parts):
return os.path.join(test_dir, "fixtures", *parts)
_LAS_SRC = """\
~VERSION INFORMATION
VERS. 2.0 : LAS VERSION 2.0
WRAP. NO : ONE LINE PER DEPTH STEP
~WELL INFORMATION
STRT.M 2500.0 : START DEPTH
STOP.M 2503.0 : STOP DEPTH
STEP.M 1.0 : STEP VALUE
NULL. -999.25 : NULL VALUE
COMP. CRESTVIEW PETROLEUM : COMPANY
WELL. IRONHORSE-3 #7 : WELL NAME
~CURVE INFORMATION
DEPT.M : MEASURED DEPTH
GR .GAPI : GAMMA RAY
CALI.IN : CALIPER
~ASCII LOG DATA
2500.0 66.33 8.51
2501.0 79.88 8.73
2502.0 58.14 8.42
2503.0 72.55 8.60
"""
def _read():
return las_rs.read(_LAS_SRC)
def _csv_text(las, **kwargs):
buf = StringIO()
las.to_csv(buf, **kwargs)
return buf.getvalue()
@pytest.mark.xfail(reason="not yet implemented")
def test_csv_custom_units():
las = _read()
custom_units = ["meters", "api", "inches"]
text = _csv_text(las, mnemonics=True, units=custom_units)
assert "meters" in text
assert "api" in text
assert "inches" in text
assert "GAPI" not in text
assert "IN" not in text
@pytest.mark.xfail(reason="not yet implemented")
def test_csv_lineterminator():
las = _read()
text = _csv_text(las, lineterminator="\r\n")
assert "\r\n" in text
@pytest.mark.xfail(reason="not yet implemented")
def test_csv_custom_mnemonics():
las = _read()
custom_mnemonics = ["Depth", "Gamma", "Caliper"]
text = _csv_text(las, mnemonics=custom_mnemonics)
for name in custom_mnemonics:
assert name in text
assert "DEPT" not in text
assert "GR" not in text
assert "CALI" not in text