def test_dataset_copied_fields():
copy_info = collect_copy_info(
Dataset,
path="dataset",
ignore_fields={
"preservation", # preservation is emptied manually
"system_creator", # hide to reduce noise
},
)
copied = {key for key, value in copy_info.items() if value == "copy"}
existing = {key for key, value in copy_info.items() if value == "existing"}
omit = {key for key, value in copy_info.items() if value == "omit"}
# Relations that should use new copies of related objects:
assert copied == {
"dataset.access_rights",
"dataset.access_rights.license",
"dataset.actors",
"dataset.actors.organization",
"dataset.actors.organization.homepage",
"dataset.actors.organization.parent",
"dataset.actors.person",
"dataset.actors.person.homepage",
"dataset.file_set.directory_metadata",
"dataset.file_set.file_metadata",
"dataset.file_set",
"dataset.other_identifiers",
"dataset.projects.funding.funder.organization.homepage",
"dataset.projects.funding.funder.organization.parent",
"dataset.projects.funding.funder.organization",
"dataset.projects.funding.funder",
"dataset.projects.funding",
"dataset.projects.participating_organizations.homepage",
"dataset.projects.participating_organizations.parent",
"dataset.projects.participating_organizations",
"dataset.projects",
"dataset.provenance.is_associated_with.organization.homepage",
"dataset.provenance.is_associated_with.organization.parent",
"dataset.provenance.is_associated_with.organization",
"dataset.provenance.is_associated_with.person.homepage",
"dataset.provenance.is_associated_with.person",
"dataset.provenance.is_associated_with",
"dataset.provenance.spatial",
"dataset.provenance.temporal",
"dataset.provenance.used_entity",
"dataset.provenance.variables.concept",
"dataset.provenance.variables.universe",
"dataset.provenance.variables",
"dataset.provenance",
"dataset.relation.entity",
"dataset.relation",
"dataset.remote_resources",
"dataset.spatial",
"dataset.temporal",
}
# Relations that should reuse the existing objects:
assert existing == {
"dataset.access_rights.access_type",
"dataset.access_rights.license.reference",
"dataset.access_rights.restriction_grounds",
"dataset.data_catalog",
"dataset.dataset_versions",
"dataset.draft_of",
"dataset.field_of_science",
"dataset.file_set.directory_metadata.storage",
"dataset.file_set.directory_metadata.use_category",
"dataset.file_set.file_metadata.file_type",
"dataset.file_set.file_metadata.file",
"dataset.file_set.file_metadata.use_category",
"dataset.file_set.files",
"dataset.file_set.storage",
"dataset.infrastructure",
"dataset.language",
"dataset.last_modified_by",
"dataset.metadata_owner",
"dataset.other_identifiers.identifier_type",
"dataset.permissions",
"dataset.projects.funding.funder.funder_type",
"dataset.provenance.event_outcome",
"dataset.provenance.lifecycle_event",
"dataset.provenance.preservation_event",
"dataset.provenance.spatial.reference",
"dataset.provenance.used_entity.type",
"dataset.relation.entity.type",
"dataset.relation.relation_type",
"dataset.remote_resources.file_type",
"dataset.remote_resources.use_category",
"dataset.spatial.reference",
"dataset.theme",
}
# Reverse relations that are not copied:
# Any parent relations that show up here (e.g. dataset.access_rights.dataset)
# should be added to corresponding parent_relations list
# (e.g. AccessRights.copier.parent_relations) to indicate they
# are intentionally omitted when creating a copy.
assert omit == {
"dataset.projects.participating_organizations.children",
"dataset.legacydataset",
"dataset.metrics",
"dataset.provenance.is_associated_with.organization.children",
"dataset.actors.organization.children",
"dataset.projects.funding.funder.organization.children",
"dataset.next_draft",
}