Skip to content

Commit

Permalink
updating test fixtures
Browse files Browse the repository at this point in the history
Co-authored-by: Chuck Daniels <[email protected]>
  • Loading branch information
SwordSaintLancelot and chuckwondo authored Jul 19, 2024
1 parent a45c20c commit 06cca63
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions tests/test_vi.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,32 +171,32 @@ def test_generate_cmr_metadata(input_dir, output_dir):
actual_metadata_path.unlink()


@pytest.fixture
def cmr_xml():
return "tests/fixtures/HLS-VI.L30.T06WVS.2024120T211159.v2.0.cmr.xml"
def test_generate_stac_items(tmp_path):
import shutil

# Since we our HLS-VI CMR XML fixture files are not in the same directory as the
# corresponding NDVI TIF files, we need to copy the NDVI TIF files to the temporary
# directory, along with the CMR XML file, so that they are both in the same
# directory. This is because our logic for creating STAC items assumes that the
# CMR XML file and the NDVI TIF file are in the same directory.

@pytest.fixture
def endpoint():
return "data.lpdaac.earthdatacloud.nasa.gov"


@pytest.fixture
def version():
return "020"


def test_generate_stac_items(cmr_xml, endpoint, version, tmp_path):
cmr_xml = "HLS-VI.L30.T06WVS.2024120T211159.v2.0.cmr.xml"
ndvi_tif = cmr_xml.replace("cmr.xml", "NDVI.tif")
fixtures = Path("tests") / "fixtures"
shutil.copy(fixtures / cmr_xml, tmp_path / cmr_xml)
shutil.copy(fixtures / ndvi_tif.rstrip(".NDVI.tif") / ndvi_tif, tmp_path / ndvi_tif)

temp_json_output = tmp_path / "temp_output.json"

create_item(
cmr_xml,
str(tmp_path / cmr_xml),
temp_json_output,
endpoint,
version,
"data.lpdaac.earthdatacloud.nasa.gov",
"020",
)

with open("tests/fixtures/HLS-VI_stac_item.json") as f:
stac_item = json.load(f)
expected_stac_item = json.load(f)
with open(temp_json_output) as f:
unit_test_stac_item = json.load(f)
assert stac_item == unit_test_stac_item
actual_stac_item = json.load(f)
assert actual_stac_item == expected_stac_item

0 comments on commit 06cca63

Please sign in to comment.