def create(self) -> Dict: """ Create a new custom basket in Marquee :return: dictionary containing asset id and report id **Usage** Create a new custom basket in Marquee **See also** :func:`get_details` :func:`poll_status` :func:`update` """ inputs, pricing, publish = {}, {}, {} for prop in CustomBasketsCreateInputs.properties(): set_(inputs, prop, get(self, prop)) for prop in CustomBasketsPricingParameters.properties(): set_(pricing, prop, get(self, prop)) for prop in PublishParameters.properties(): set_(publish, prop, get(self, prop)) set_(inputs, 'position_set', self.position_set.to_target(common=False)) set_(inputs, 'pricing_parameters', CustomBasketsPricingParameters(**pricing)) set_(inputs, 'publish_parameters', PublishParameters(**publish)) create_inputs = CustomBasketsCreateInputs(**inputs) response = GsIndexApi.create(create_inputs) gs_asset = GsAssetApi.get_asset(response.asset_id) self.__latest_create_report = GsReportApi.get_report( response.report_id) self.__init__(gs_asset=gs_asset, _finish_init=True) return response.as_dict()
def test_basket_create(mocker): # construct inputs and mock response inputs = CustomBasketsCreateInputs(name, position_set, pricing_parameters, return_type, ticker, publish_parameters=publish_parameters) mock_response = CustomBasketsResponse(report_id, basket_id, 'done') # setup mock session and api response mock_session() mocker.return_value = mock_response # run test response = GsIndexApi.create(inputs) assert response == mock_response