def test_upload(self, mocked_get_container_path, mocked_get_connection): """ Test and assert that ObjectStore.connection.put_object is called with the correct arguments """ mocked_get_container_path.return_value = 'container/path/' objstore = ObjectStore(config='this is the config') connection = Connection() connection.put_object = Mock() mocked_get_connection.return_value = connection file = ('mock', 'file') document = Document(filename='doc_file_name.pdf', type=Document.DocumentType.Ontwerp) objstore.upload(file, document) connection.put_object.assert_called_with('container/path/', 'doc_file_name.pdf', file)
def handle_documents(self, spot, rapport_file=None, design_file=None): objstore = ObjectStore(settings.OBJECTSTORE_CONNECTION_CONFIG) if rapport_file: try: rapport_document, created = Document.objects.get_or_create( type=Document.DocumentType.Rapportage, spot=spot) objstore.upload(rapport_file, rapport_document) except: # noqa E722 - ignore flake8 check, using bare except raise if design_file: try: design_document, created = Document.objects.get_or_create( type=Document.DocumentType.Ontwerp, spot=spot) objstore.upload(design_file, design_document) except: # noqa E722 - ignore flake8 check, using bare except raise