Tests versioning in dataset
Current very basic versioning scheme (Research Dataset has foreign keys next, first, last, and so on..) is
probably going to be replaced with django-simple-history library.
Parameters:
Name |
Type |
Description |
Default |
published_dataset |
|
|
required
|
Returns: New instance of the Research Dataset with the modified fields
Source code in tests/behave/features/qvain/test_versioning.py
| @pytest.fixture
@when("edited dataset is saved as a new version of the dataset")
def created_new_dataset_version(published_dataset):
"""Tests versioning in dataset
Current very basic versioning scheme (Research Dataset has foreign keys next, first, last, and so on..) is
probably going to be replaced with django-simple-history library.
Args:
published_dataset (): Research Dataset Object
Returns: New instance of the Research Dataset with the modified fields
"""
raise NotImplementedError
original_fields = model_to_dict(published_dataset)
logger.info(original_fields)
del original_fields["data_catalog"]
del original_fields["language"]
del original_fields["contract"]
del original_fields["system_creator"]
del original_fields["creator"]
new_version = Dataset(**original_fields)
new_version = ResearchDataset(**original_fields)
new_version.data_catalog = published_dataset.data_catalog
new_version.title = {"en": "new title"}
new_version.replaces = published_dataset
new_version.previous = published_dataset
new_version.save()
published_dataset.save()
return new_version
|