Skip to content
Snippets Groups Projects
Commit 37b3b00e authored by Benjamin Becker's avatar Benjamin Becker
Browse files

fixes unit tests

parent f15e8422
Branches fix-get_action-calls
Tags
No related merge requests found
......@@ -181,8 +181,8 @@ class TestWriteThumbnailIntoPackage(object):
call('package_update')
])
p.mock_action_handler.assert_has_calls([
call(self.context, {'id': 'foo'}),
call(self.context, {'id': 'foo', 'thumbnail': 'filename'})
call(None, {'id': 'foo'}),
call(None, {'id': 'foo', 'thumbnail': 'filename'})
])
@p.patch_get_action
......@@ -193,8 +193,8 @@ class TestWriteThumbnailIntoPackage(object):
call('package_update')
])
p.mock_action_handler.assert_has_calls([
call(self.context, {'id': 'foo'}),
call(self.context, {'id': 'foo'})
call(None, {'id': 'foo'}),
call(None, {'id': 'foo'})
])
......@@ -218,6 +218,7 @@ class TestCreateThumbnailIfNoneInPackage(object):
@p.patch_get_package_dict_from_context
def test_creates_thumbnail_for_first_resource(self, patch_gpdfc, patch_ct, patch_ga):
patch_ct.side_effect = [(True, 'filename1'), (True, 'filename2')]
patch_gpdfc.return_value = {}
thumbnail.create_thumbnail_if_none_in_package(self.context, ['resource1', 'resource2'])
patch_ct.assert_called_once_with(self.context, 'resource1')
......@@ -226,6 +227,7 @@ class TestCreateThumbnailIfNoneInPackage(object):
@p.patch_get_package_dict_from_context
def test_creates_thumbnail_for_first_pdf(self, patch_gpdfc, patch_ct, patch_ga):
patch_ct.side_effect = [(False, 'filename1'), (True, 'filename2'), (True, 'filename3')]
patch_gpdfc.return_value = {}
thumbnail.create_thumbnail_if_none_in_package(self.context, ['resource1', 'resource2', 'resource3'])
patch_ct.assert_called_with(self.context, 'resource2')
......@@ -243,6 +245,7 @@ class TestCreateThumbnailIfNoneInPackage(object):
@p.patch_create_thumbnail
@p.patch_get_package_dict_from_context
def test_does_not_create_thumbnail_if_no_resources(self, patch_gpdfc, patch_ct, patch_ga):
patch_gpdfc.return_value = {}
thumbnail.create_thumbnail_if_none_in_package(self.context, [])
patch_ct.assert_not_called()
......@@ -252,6 +255,7 @@ class TestCreateThumbnailIfNoneInPackage(object):
@p.patch_get_package_dict_from_context
def test_writes_filename_into_package(self, patch_gpdfc, patch_ct, patch_ga, patch_wtip):
patch_ct.side_effect = [(True, 'filename1'), (True, 'filename2')]
patch_gpdfc.return_value = {}
thumbnail.create_thumbnail_if_none_in_package(self.context, ['resource1'])
patch_wtip.assert_called_once_with(self.context, 'filename1')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment