Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dmrpp relative path integration test #318

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions virtualizarr/tests/test_readers/test_dmrpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


@pytest.fixture
def basic_dmrpp() -> DMRParser:
def basic_dmrpp_xml_str() -> str:
xml_str = """\
<?xml version="1.0" encoding="ISO-8859-1"?>
<Dataset xmlns="http://xml.opendap.org/ns/DAP/4.0#" xmlns:dmrpp="http://xml.opendap.org/dap/dmrpp/1.0.0#" dapVersion="4.0" dmrVersion="1.0" name="test.dmrpp">
Expand Down Expand Up @@ -111,11 +111,11 @@ def basic_dmrpp() -> DMRParser:
</Attribute>
</Dataset>
"""
return DMRParser(root=ET.fromstring(textwrap.dedent(xml_str)))
return textwrap.dedent(xml_str)


@pytest.fixture
def nested_groups_dmrpp() -> DMRParser:
def nested_groups_dmrpp_xml_str() -> str:
xml_str = """\
<?xml version="1.0" encoding="ISO-8859-1"?>
<Dataset xmlns="http://xml.opendap.org/ns/DAP/4.0#" xmlns:dmrpp="http://xml.opendap.org/dap/dmrpp/1.0.0#" dapVersion="4.0" dmrVersion="1.0" name="test.dmrpp">
Expand Down Expand Up @@ -166,7 +166,24 @@ def nested_groups_dmrpp() -> DMRParser:
</Group>
</Dataset>
"""
return DMRParser(root=ET.fromstring(textwrap.dedent(xml_str)))
return textwrap.dedent(xml_str)


@pytest.fixture
def basic_dmrpp_temp_filepath(basic_dmrpp_xml_str, tmp_path) -> Path:
dmrpp_path = tmp_path / "basic.nc.dmrpp"
dmrpp_path.write_text(basic_dmrpp_xml_str)
return dmrpp_path


@pytest.fixture
def basic_dmrpp(basic_dmrpp_xml_str) -> DMRParser:
return DMRParser(root=ET.fromstring(basic_dmrpp_xml_str))


@pytest.fixture
def nested_groups_dmrpp(nested_groups_dmrpp_xml_str) -> DMRParser:
return DMRParser(root=ET.fromstring(nested_groups_dmrpp_xml_str))


@network
Expand All @@ -178,6 +195,13 @@ def test_NASA_dmrpp(data_url, dmrpp_url):
xr.testing.assert_identical(result, expected)


def test_relative_path(basic_dmrpp_temp_filepath):
vds = open_virtual_dataset(
str(basic_dmrpp_temp_filepath), indexes={}, filetype="dmrpp"
)
assert vds["x"].data.manifest["0"].path.endswith("basic.nc")


@pytest.mark.parametrize(
"dmrpp_fixture, fqn_path, expected_xpath",
[
Expand Down
Loading