From c6bcd5f50b792547963e82604992c71c145e000c Mon Sep 17 00:00:00 2001 From: James Graham <J.Graham@software.ac.uk> Date: Tue, 19 Feb 2019 11:23:48 +0000 Subject: [PATCH] Fix failing PROV tests caused by invalid plugin name --- .../migrations/0031_default_connector_name.py | 18 ++++++++++++++++++ datasources/models.py | 1 + provenance/tests.py | 17 +++++++++++++---- 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 datasources/migrations/0031_default_connector_name.py diff --git a/datasources/migrations/0031_default_connector_name.py b/datasources/migrations/0031_default_connector_name.py new file mode 100644 index 0000000..13f8306 --- /dev/null +++ b/datasources/migrations/0031_default_connector_name.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.8 on 2019-02-19 10:27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('datasources', '0030_rename_licence'), + ] + + operations = [ + migrations.AlterField( + model_name='datasource', + name='plugin_name', + field=models.CharField(default='DataSetConnector', max_length=63), + ), + ] diff --git a/datasources/models.py b/datasources/models.py index ef6abbc..5942754 100644 --- a/datasources/models.py +++ b/datasources/models.py @@ -239,6 +239,7 @@ class DataSource(BaseAppDataModel): #: Name of plugin which allows interaction with this data source plugin_name = models.CharField(max_length=MAX_LENGTH_NAME, + default='DataSetConnector', blank=False, null=False) #: If the data source API requires an API key use this one diff --git a/provenance/tests.py b/provenance/tests.py index 21029c6..53e2bd6 100644 --- a/provenance/tests.py +++ b/provenance/tests.py @@ -39,7 +39,6 @@ class ProvEntryTest(TestCase): name='Test Data Source', url='http://www.example.com', owner=self.user, - plugin_name='TEST' ) def tearDown(self): @@ -99,7 +98,6 @@ class ProvWrapperTest(TestCase): name='Test Data Source', url='http://www.example.com', owner=self.user, - plugin_name='TEST' ) def tearDown(self): @@ -130,12 +128,24 @@ class ProvWrapperTest(TestCase): """ n_provs = self._count_prov(self.datasource) - self.datasource.plugin_name = 'CHANGED' + self.datasource.api_key = 'TEST' self.datasource.save() # Another PROV record should be created when model is changed and saved self.assertEqual(self._count_prov(self.datasource), n_provs + 1) + @unittest.expectedFailure + def test_prov_datasource_no_update(self): + """ + Test that a new :class:`ProvEntry` is not created when a model is saved without changes. + """ + n_provs = self._count_prov(self.datasource) + + self.datasource.save() + + # Another PROV record should be created when model is changed and saved + self.assertEqual(self._count_prov(self.datasource), n_provs) + @unittest.expectedFailure def test_prov_datasource_null_update(self): """ @@ -158,7 +168,6 @@ class ProvWrapperTest(TestCase): name='Another Test Data Source', url='http://www.example.com', owner=self.user, - plugin_name='TEST' ) new_prov_entries = models.ProvWrapper.filter_model_instance(new_datasource) -- GitLab