def test_create_event(self, event): event_controller = EventController() # Mocking upload inside EventController event_controller.upload_service = Mock() result = event_controller.create(event) assert result is True
def test_create_event_with_none(self): event_controller = EventController() # Mocking db inside EventController event_controller.db = Mock() event_controller.upload_service = Mock() result = event_controller.create(None) assert result is False
def test_create_event_with_upload_service_error(self, event): event_controller = EventController() event_controller.db = Mock() event_controller.upload_service = Mock() event_controller.upload_service.upload_from_url.side_effect = Exception result = event_controller.create(event.__dict__) assert result == (False, ConnectionRefusedError)
def test_create_event_with_db_connection_error(self, event): event_controller = EventController() event_controller.db = Mock() event_controller.db.insert.side_effect = Exception event_controller.upload_service = Mock() result, excp = event_controller.create(event.__dict__) assert result == False assert excp == ConnectionError
def event_create(): event = { "name": request.form['name'], "description": request.form['description'], "place": request.form['place'], "day": request.form['day'], "picture": request.form['picture'], } event_controller = EventController() result = event_controller.create(event) return {}, 201