Skip to content

Commit

Permalink
Remove tests for archived survey occurrence v1 template
Browse files Browse the repository at this point in the history
Add missing test for survey occurrence v2
  • Loading branch information
Lincoln-GR committed Dec 11, 2024
1 parent c1064a5 commit e95f62d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 292 deletions.
292 changes: 0 additions & 292 deletions tests/templates/test_survey_occurrence_data.py

This file was deleted.

41 changes: 41 additions & 0 deletions tests/templates/test_survey_occurrence_data_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,3 +514,44 @@ def test_apply_validation(self, scenario: Scenario, mocker: pytest_mock.MockerFi
if not report.valid:
error_codes = [code for codes in report.flatten(["type"]) for code in codes]
assert set(error_codes) == scenario.expected_error_codes


def test_extract_site_id_keys(
mocker: pytest_mock.MockerFixture,
mapper: Mapper,
) -> None:
"""Test the extract_site_id_keys method.
Args:
mocker (pytest_mock.MockerFixture): The mocker fixture.
"""
# Construct a raw data set only using fields relevant to method.
rawh = ["siteID"]
raws = [["site1"], [""], ["site2"], ["site3"], ["site3"]]

# Amalgamate into a list of dicts
all_raw = [{hname: val for hname, val in zip(rawh, ln, strict=True)} for ln in raws]

# Modify schema to only include the necessary fields
descriptor = {"fields": [{"name": "siteID", "type": "string"}]}
mocker.patch.object(base.mapper.ABISMapper, "schema").return_value = descriptor

# Create raw data csv string
output = io.StringIO()
csv_writer = csv.DictWriter(output, fieldnames=rawh)
csv_writer.writeheader()
for row in all_raw:
csv_writer.writerow(row)
csv_data = output.getvalue().encode("utf-8")

expected = {
"site1": True,
"site2": True,
"site3": True,
}

# Invoke method
actual = mapper.extract_site_id_keys(csv_data)

# Validate
assert actual == expected

0 comments on commit e95f62d

Please sign in to comment.