Example #1
0
 def test_retrieve_asset_file_missing_sheet(self, registry_with_content):
     from adhocracy_core.exceptions import RuntimeConfigurationError
     from adhocracy_core.sheets.asset import retrieve_asset_file
     context = testing.DummyResource()
     registry_with_content.content.get_sheet.side_effect =\
         RuntimeConfigurationError
     with raises(RuntimeConfigurationError):
         retrieve_asset_file(context, registry_with_content)
Example #2
0
 def test_retrieve_asset_file_successfully(self, monkeypatch, registry):
     from adhocracy_core import utils
     from adhocracy_core.sheets.asset import IAssetData, retrieve_asset_file
     mock_sheet = Mock()
     mock_sheet.get.return_value = {'data': 'dummy'}
     mock_get_sheet = Mock(spec=utils.get_sheet, return_value=mock_sheet)
     monkeypatch.setattr(utils, 'get_sheet', mock_get_sheet)
     context = testing.DummyResource(__provides__=IAssetData)
     assert retrieve_asset_file(context, registry) == 'dummy'
Example #3
0
 def get(self) -> dict:
     """Get asset data (unless deleted or hidden)."""
     file = retrieve_asset_file(self.context, self.request.registry)
     response = file.get_response(self.context, self.request.registry)
     self.ensure_caching_headers(response)
     return response