def test_create_new_version(language, theme, dataset):
DatasetActorFactory.create_batch(2, dataset=dataset, roles=["creator"])
ProvenanceFactory(dataset=dataset)
dataset.language.add(language)
dataset.theme.add(theme)
old_version = dataset
dataset.publish()
new_version = Dataset.create_new_version(dataset)
assert new_version.id != old_version.id
assert new_version.published_revision == 0
assert old_version.language.all().count() != 0
assert old_version.theme.all().count() != 0
assert old_version.actors.all().count() != 0
assert old_version.language.all().count() == new_version.language.all().count()
assert old_version.theme.all().count() == new_version.theme.all().count()
assert old_version.field_of_science.all().count() == new_version.field_of_science.all().count()
assert old_version.actors.all().count() == new_version.actors.all().count()
assert old_version.access_rights.id != new_version.access_rights.id
assert old_version.actors.difference(new_version.actors.all()).count() == 3
assert old_version.provenance.difference(new_version.provenance.all()).count() == 1
assert new_version.permissions_id == old_version.permissions_id
assert new_version.dataset_versions_id == old_version.dataset_versions_id
# Preservation status is reset for new version
assert old_version.preservation
assert not new_version.preservation