def _test(self, private_storage_mock, ZipFile_mock, save_icon_mock, **kwargs): fetch_icon(self.extension.pk, **kwargs) # We've opened file_path. eq_(private_storage_mock.open.call_count, 1) eq_(private_storage_mock.open.call_args_list[0][0], (self.version.file_path, )) # We've used it as a zip file, looking for the 128 icon (stripping # leading '/'). eq_(ZipFile_mock.call_count, 1) eq_(ZipFile_mock.call_args_list[0][0], (private_storage_mock.open().__enter__.return_value, )) eq_(ZipFile_mock().__enter__().read.call_count, 1) eq_(ZipFile_mock().__enter__().read.call_args_list[0][0], ('path/to/icon.png', )) # We've passed the extension and icon contents to save_icon. eq_(save_icon_mock.call_count, 1) eq_(save_icon_mock.call_args_list[0][0], (self.extension, ZipFile_mock().__enter__().read.return_value, ))
def _test_nothing_called(self, private_storage_mock, ZipFile_mock, save_icon_mock, **kwargs): fetch_icon(self.extension.pk, **kwargs) eq_(private_storage_mock.open.call_count, 0) eq_(ZipFile_mock.call_count, 0) eq_(save_icon_mock.call_count, 0)