def test_manage_feed_subscription_response(self): poll_instance1 = tm10.PollInstance( poll_protocol=t.VID_TAXII_HTTP_10, # Required poll_address='http://example.com/poll', # Required poll_message_bindings=[t.VID_TAXII_XML_10]) # Required subscription_instance1 = tm10.SubscriptionInstance( subscription_id='SubsId234', # required delivery_parameters=delivery_parameters1, # Required if message is responding to a status action. Optional otherwise poll_instances=[poll_instance1]) # Required if action was polling subscription. Optional otherwise manage_feed_subscription_response1 = tm10.ManageFeedSubscriptionResponse( message_id=tm10.generate_message_id(), # Required in_response_to=tm10.generate_message_id(), # Required - Should be the ID of the corresponding request feed_name='Feed001', # Required message='This is a message', # Optional subscription_instances=[subscription_instance1]) # Required round_trip_message(manage_feed_subscription_response1)
def subscription_to_subscription_instance(subscription, polling_services, version, subscription_parameters=None): polling_instances = [] for poll in polling_services: polling_instances.extend( poll_service_to_polling_service_instance( poll, version=version, is_poll_instance_cls=True)) params = dict( subscription_id=subscription.subscription_id, poll_instances=polling_instances, ) if version == 10: params['delivery_parameters'] = None return tm10.SubscriptionInstance(**params) if version == 11: push_params = None params.update( dict( status=subscription.status, push_parameters=push_params, )) if subscription_parameters: bindings = content_binding_entities_to_content_bindings( subscription_parameters.content_bindings, version=version) params['subscription_parameters'] = tm11.SubscriptionParameters( response_type=subscription_parameters.response_type, content_bindings=bindings) return tm11.SubscriptionInstance(**params) raise ValueError('invalid version')