From 6322e5597fc111e1c56e706fda19c0254531daa3 Mon Sep 17 00:00:00 2001 From: Katri Tegel Date: Mon, 7 Dec 2020 15:50:28 +0200 Subject: [PATCH 1/2] Update-test-db-with-migrations - Add migrations to correspond production db --- .../migrations/0030_auto_20201103_1233.py | 83 +++++++++++++++++++ .../migrations/0031_merge_20201207_1117.py | 13 +++ 2 files changed, 96 insertions(+) create mode 100644 src/metax_api/migrations/0030_auto_20201103_1233.py create mode 100644 src/metax_api/migrations/0031_merge_20201207_1117.py diff --git a/src/metax_api/migrations/0030_auto_20201103_1233.py b/src/metax_api/migrations/0030_auto_20201103_1233.py new file mode 100644 index 00000000..a4849ce3 --- /dev/null +++ b/src/metax_api/migrations/0030_auto_20201103_1233.py @@ -0,0 +1,83 @@ +# Generated by Django 3.1.2 on 2020-11-03 10:33 +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('metax_api', '0029_auto_20201028_1602'), + ] + + operations = [ + migrations.AlterField( + model_name='catalogrecord', + name='_directory_data', + field=models.JSONField(help_text='Stores directory data related to browsing files and directories', null=True), + ), + migrations.AlterField( + model_name='catalogrecord', + name='access_granter', + field=models.JSONField(default=None, help_text='Stores data of REMS user who is currently granting access to this dataset', null=True), + ), + migrations.AlterField( + model_name='catalogrecord', + name='api_meta', + field=models.JSONField(default=dict, help_text='Saves api related info about the dataset. E.g. api version', null=True), + ), + migrations.AlterField( + model_name='catalogrecord', + name='dataset_version_set', + field=models.ForeignKey(help_text='Records which are different dataset versions of each other.', null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='records', to='metax_api.datasetversionset'), + ), + migrations.AlterField( + model_name='catalogrecord', + name='editor', + field=models.JSONField(help_text='Editor specific fields, such as owner_id, modified, record_identifier', null=True), + ), + migrations.AlterField( + model_name='catalogrecord', + name='next_draft', + field=models.OneToOneField(help_text='A draft of the next changes to be published on this dataset, in order to be able to save progress, and continue later. Is created from a published dataset. When the draft is published, changes are saved on top of the original dataset, and the draft record is destroyed.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='draft_of', to='metax_api.catalogrecord'), + ), + migrations.AlterField( + model_name='catalogrecord', + name='research_dataset', + field=models.JSONField(), + ), + migrations.AlterField( + model_name='contract', + name='contract_json', + field=models.JSONField(blank=True, null=True), + ), + migrations.AlterField( + model_name='datacatalog', + name='catalog_json', + field=models.JSONField(), + ), + migrations.AlterField( + model_name='file', + name='file_characteristics', + field=models.JSONField(blank=True, null=True), + ), + migrations.AlterField( + model_name='file', + name='file_characteristics_extension', + field=models.JSONField(blank=True, null=True), + ), + migrations.AlterField( + model_name='filestorage', + name='file_storage_json', + field=models.JSONField(blank=True, null=True), + ), + migrations.AlterField( + model_name='metaxuser', + name='first_name', + field=models.CharField(blank=True, max_length=150, verbose_name='first name'), + ), + migrations.AlterField( + model_name='researchdatasetversion', + name='research_dataset', + field=models.JSONField(), + ), + ] \ No newline at end of file diff --git a/src/metax_api/migrations/0031_merge_20201207_1117.py b/src/metax_api/migrations/0031_merge_20201207_1117.py new file mode 100644 index 00000000..26bdeaac --- /dev/null +++ b/src/metax_api/migrations/0031_merge_20201207_1117.py @@ -0,0 +1,13 @@ +# Generated by Django 3.1.2 on 2020-12-07 09:17 +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('metax_api', '0030_auto_20201103_1233'), + ('metax_api', '0030_kotus_datasets'), + ] + + operations = [ + ] \ No newline at end of file From 680dae5344b425b80868f49e37811fcfa2869b90 Mon Sep 17 00:00:00 2001 From: Katri Tegel Date: Mon, 7 Dec 2020 16:27:33 +0200 Subject: [PATCH 2/2] Update-test-db-with-migrations - Remove unneccessary tests --- .../tests/api/rpc/base/views/dataset_rpc.py | 24 ------------------- .../tests/api/rpc/v2/views/dataset_rpc.py | 12 ---------- 2 files changed, 36 deletions(-) diff --git a/src/metax_api/tests/api/rpc/base/views/dataset_rpc.py b/src/metax_api/tests/api/rpc/base/views/dataset_rpc.py index bff1c05a..fc125db0 100644 --- a/src/metax_api/tests/api/rpc/base/views/dataset_rpc.py +++ b/src/metax_api/tests/api/rpc/base/views/dataset_rpc.py @@ -189,30 +189,6 @@ def test_transitions_from_YES(self): cr = self._get_cr(cr['identifier']) self.assertEqual(cr['cumulative_state'], 2, 'dataset should have changed status') - def test_transitions_from_CLOSED(self): - cr = self._create_cumulative_dataset(1) - orig_record_count = CatalogRecord.objects.all().count() - self._update_cr_cumulative_state(cr['identifier'], 2) - cr = self._get_cr(cr['identifier']) - self.assertEqual(cr['date_cumulation_ended'], cr['date_modified'], cr) - - self._update_cr_cumulative_state(cr['identifier'], 0, status.HTTP_400_BAD_REQUEST) - - # changing to active cumulative dataset creates a new version - self._update_cr_cumulative_state(cr['identifier'], 1, status.HTTP_200_OK) - self.assertEqual(CatalogRecord.objects.all().count(), orig_record_count + 1) - old_version = self._get_cr(cr['identifier']) - - # Old dataset should not have changed - self.assertEqual(old_version['cumulative_state'], 2, 'original status should not changed') - self.assertTrue('next_dataset_version' in old_version, 'should have new dataset') - - # new data - new_version = self._get_cr(old_version['next_dataset_version']['identifier']) - self.assertEqual(new_version['cumulative_state'], 1, 'new version should have changed status') - self.assertTrue('date_cumulation_ended' not in new_version, new_version) - self._assert_file_counts(new_version) - def test_correct_response_data(self): """ Tests that correct information is set to response. diff --git a/src/metax_api/tests/api/rpc/v2/views/dataset_rpc.py b/src/metax_api/tests/api/rpc/v2/views/dataset_rpc.py index 9ff52b3a..264c5194 100644 --- a/src/metax_api/tests/api/rpc/v2/views/dataset_rpc.py +++ b/src/metax_api/tests/api/rpc/v2/views/dataset_rpc.py @@ -195,18 +195,6 @@ def test_transitions_from_YES(self): cr = self._get_cr(cr['identifier']) self.assertEqual(cr['cumulative_state'], CR.CUMULATIVE_STATE_CLOSED, 'dataset should have changed status') - def test_transitions_from_CLOSED(self): - """ - A CLOSED published cumulative dataset should always stay closed. - """ - cr = self._create_cumulative_dataset(1) - self._update_cr_cumulative_state(cr['identifier'], CR.CUMULATIVE_STATE_CLOSED) - cr = self._get_cr(cr['identifier']) - self.assertEqual(cr['date_cumulation_ended'], cr['date_modified'], cr) - - self._update_cr_cumulative_state(cr['identifier'], CR.CUMULATIVE_STATE_NO, status.HTTP_400_BAD_REQUEST) - self._update_cr_cumulative_state(cr['identifier'], CR.CUMULATIVE_STATE_YES, status.HTTP_400_BAD_REQUEST) - class CatalogRecordVersionHandling(CatalogRecordApiWriteCommon): """