Skip to content

Commit

Permalink
Test that wrong fields are not initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
jl-wynen committed Aug 16, 2023
1 parent 9fc159a commit 8568155
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def raw_download_model():
def derived_download_model():
return model.DownloadDataset(
contactEmail="p.stibbons@uu.am",
creationLocation="UnseenUniversity",
creationLocation=None,
creationTime=parse_datetime("1995-08-06T14:14:14Z"),
inputDatasets=[PID.parse("123.cc/948.f7.2a")],
investigator="Ponder Stibbons",
Expand All @@ -111,7 +111,7 @@ def derived_download_model():
dataFormat=None,
dataQualityMetrics=24,
description="Dubiously analyzed data",
endTime=parse_datetime("1995-08-03T00:00:00Z"),
endTime=None,
history=None,
instrumentGroup="professors",
instrumentId=None,
Expand Down Expand Up @@ -179,6 +179,13 @@ def get_model_field(name):
assert getattr(dset, field.name) == get_model_field(field.scicat_name)


def test_from_download_models_does_not_initialize_wrong_fields(dataset_download_model):
dset = Dataset.from_download_models(dataset_download_model, [])
for field in dset.fields():
if not field.used_by(dataset_download_model.type):
assert getattr(dset, field.name) is None


@pytest.mark.parametrize("typ", (DatasetType.RAW, DatasetType.DERIVED))
def test_new_dataset_has_no_files(typ):
dset = Dataset(type=typ)
Expand Down

0 comments on commit 8568155

Please sign in to comment.