Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #712 from CSCfi/Update-test-db-with-migrations
Browse files Browse the repository at this point in the history
Update test db with migrations
  • Loading branch information
katrite authored Dec 8, 2020
2 parents 4453c6e + 680dae5 commit 335f8c5
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 36 deletions.
83 changes: 83 additions & 0 deletions src/metax_api/migrations/0030_auto_20201103_1233.py
Original file line number Diff line number Diff line change
@@ -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(),
),
]
13 changes: 13 additions & 0 deletions src/metax_api/migrations/0031_merge_20201207_1117.py
Original file line number Diff line number Diff line change
@@ -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 = [
]
24 changes: 0 additions & 24 deletions src/metax_api/tests/api/rpc/base/views/dataset_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 0 additions & 12 deletions src/metax_api/tests/api/rpc/v2/views/dataset_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

"""
Expand Down

0 comments on commit 335f8c5

Please sign in to comment.