From 8d9208544f8c9e7bb508220d956c834882365bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aitor=20Mag=C3=A1n?= Date: Tue, 21 Oct 2014 17:50:16 +0200 Subject: [PATCH] Fix tests --- ckanext/privatedatasets/plugin.py | 2 +- ckanext/privatedatasets/tests/test_plugin.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ckanext/privatedatasets/plugin.py b/ckanext/privatedatasets/plugin.py index 71c18d4..714a2dc 100644 --- a/ckanext/privatedatasets/plugin.py +++ b/ckanext/privatedatasets/plugin.py @@ -199,7 +199,7 @@ class PrivateDatasets(p.SingletonPlugin, tk.DefaultDatasetForm): 'use_cache': False}, {'id': package_id}) # Prevent acquired datasets jumping to the first position - new_pkg_dict['metadata_modified'] = new_pkg_dict['revision_timestamp'] + new_pkg_dict['metadata_modified'] = new_pkg_dict.get('revision_timestamp', '') self.indexer.update_dict(new_pkg_dict) return pkg_dict diff --git a/ckanext/privatedatasets/tests/test_plugin.py b/ckanext/privatedatasets/tests/test_plugin.py index ff7fd68..b32f696 100644 --- a/ckanext/privatedatasets/tests/test_plugin.py +++ b/ckanext/privatedatasets/tests/test_plugin.py @@ -282,8 +282,10 @@ class PluginTest(unittest.TestCase): package_id = 'package_id' # Configure mocks - default_dict = {'a': '0', 'b': 1, 'm': True} - package_show = MagicMock(return_value=default_dict) + default_dict = {'a': '0', 'b': 1, 'm': True, 'revision_timestamp': '2000'} + expected_dict = default_dict.copy() + expected_dict['metadata_modified'] = default_dict['revision_timestamp'] + package_show = MagicMock(return_value=default_dict.copy()) plugin.tk.get_action = MagicMock(return_value=package_show) # Each time 'AllowedUser' is called, we must get a new instance @@ -336,7 +338,7 @@ class PluginTest(unittest.TestCase): self.assertEquals(0, self.privateDatasets.indexer.update_dict.call_count) else: # Check that the cache has been updated - self.privateDatasets.indexer.update_dict.assert_called_once_with(default_dict) + self.privateDatasets.indexer.update_dict.assert_called_once_with(expected_dict) @parameterized.expand([ # One element