Assert that an event meets the protocol for datasource outputs.
500973
def assert_datasource_protocol(event):
    """"""

    assert event.type in DATASOURCE_TYPE

    # Done packets have no dt.
    if not event.type == DATASOURCE_TYPE.DONE:
        assert isinstance(event.dt, datetime)
        assert event.dt.tzinfo == pytz.utc
225427
def validate(identifier):
    ''''''
    source = actions.validate_source(identifier)
    log.info('Source %s (%s) has been validated', source.slug, str(source.id))
190532
protected void assertEndBraceExists(Method executeMethod, String urlPattern, int index) {
        if (index >= 0) {
            throwUrlPatternEndBraceNotFoundException(executeMethod, urlPattern, index);
        }
    }
505760
def validate_event_and_assign_id(event):
  
  event_time = event.get(TIMESTAMP_FIELD)

  if event_time is None:
    event[TIMESTAMP_FIELD] = event_time = epoch_time_to_kronos_time(time.time())
  elif type(event_time) not in (int, long):
    raise InvalidEventTime(event_time)

  # Generate a uuid1-like sequence from the event time with the non-time bytes
  # set to random values.
  _id = uuid_from_kronos_time(event_time)
  event[ID_FIELD] = str(_id)
  return _id, event
557600
def isHandlerPresent(self, event_name):
        """"""
        if event_name not in self.handlers:
            raise ValueError('{} is not a valid event'.format(event_name))
        return self.handlers[event_name] is not None
583827
def verify(dataset, publication_date, source, refernce_url):
    """"""

    config = ApiConfig()
    client = ApiClient(config.host, config.app_id, config.app_secret)
    client.check_correct_host()
    client.verify(dataset, publication_date, source, refernce_url)
1178073
def validate(cls, event_info):
        """"""
        assert 'routing_key' in event_info
        assert isinstance(event_info['routing_key'], six.string_types)
        assert 'event_action' in event_info
        assert event_info['event_action'] in cls.EVENT_TYPES
        assert 'payload' in event_info
        payload = event_info['payload']
        assert payload['summary']
        assert payload['source']
        assert payload['severity'] in cls.SEVERITY_TYPES
1234202
def assert_valid(self, instance, value=None):
        """"""
        valid = super(Union, self).assert_valid(instance, value)
        if not valid:
            return False
        if value is None:
            value = instance._get(self.name)
            if value is None:
                return True
        return self._try_prop_method(instance, value, 'assert_valid')
920979
private static void assertProducer(InteractionUnit unit, Map<QName, Set<Procedure>> behaviours, IntegrityErrors err) {
        Set<Resource<ResourceType>> consumedTypes = unit.getInputs();

        for (Resource<ResourceType> resource : consumedTypes) {
            boolean match = false;

            for(QName id : behaviours.keySet())
            {
                for (Behaviour candidate : behaviours.get(id)) {
                    if (candidate.doesProduce(resource)) {
                        match = candidate.getJustification() == null || unit.getId().equals(candidate.getJustification());
                    }

                    if(match)break;
                }

                if(match)break;
            }

            if (!match)
                err.add(unit.getId(), "Missing producer for <<" + resource + ">>");
        }
    }
356910
def event_return(events):
    '''
    
    '''

    for event in events:
        ret = event.get('data', False)

        if ret:
            returner(ret)
271235
def validate(cls, event_info):
        """"""
        assert 'service_key' in event_info
        assert isinstance(event_info['service_key'], six.string_types)
        assert 'event_type' in event_info
        assert event_info['event_type'] in cls.EVENT_TYPES
        if event_info['event_type'] != cls.EVENT_TYPES[0]:
            assert 'incident_key' in event_info
            assert isinstance(event_info['incident_key'], six.string_types)
        else:
            assert 'description' in event_info

        if 'details' in event_info:
            assert isinstance(event_info['details'], dict)

        if 'contexts' in event_info:
            assert isinstance(event_info['contexts'], (list, tuple,))
299444
def validate(self, protocol_version):
        """"""
        const = get_const(protocol_version)
        valid_node_ids = vol.All(vol.Coerce(int), vol.Range(
            min=0, max=BROADCAST_ID, msg='Not valid node_id: {}'.format(
                self.node_id)))
        valid_child_ids = vol.All(vol.Coerce(int), vol.Range(
            min=0, max=SYSTEM_CHILD_ID, msg='Not valid child_id: {}'.format(
                self.child_id)))
        if self.type in (const.MessageType.internal, const.MessageType.stream):
            valid_child_ids = vol.All(vol.Coerce(int), vol.In(
                [SYSTEM_CHILD_ID],
                msg='When message type is {}, child_id must be {}'.format(
                    self.type, SYSTEM_CHILD_ID)))
        if (self.type == const.MessageType.internal and
                self.sub_type in [
                    const.Internal.I_ID_REQUEST,
                    const.Internal.I_ID_RESPONSE]):
            valid_child_ids = vol.Coerce(int)
        valid_types = vol.All(vol.Coerce(int), vol.In(
            [member.value for member in const.VALID_MESSAGE_TYPES],
            msg='Not valid message type: {}'.format(self.type)))
        if self.child_id == SYSTEM_CHILD_ID:
            valid_types = vol.All(vol.Coerce(int), vol.In(
                [const.MessageType.presentation.value,
                 const.MessageType.internal.value,
                 const.MessageType.stream.value],
                msg=(
                    'When child_id is {}, {} is not a valid '
                    'message type'.format(SYSTEM_CHILD_ID, self.type))))
        valid_ack = vol.In([0, 1], msg='Not valid ack flag: {}'.format(
            self.ack))
        valid_sub_types = vol.In(
            [member.value for member
             in const.VALID_MESSAGE_TYPES.get(self.type, [])],
            msg='Not valid message sub-type: {}'.format(self.sub_type))
        valid_payload = const.VALID_PAYLOADS.get(
            self.type, {}).get(self.sub_type, '')
        schema = vol.Schema({
            'node_id': valid_node_ids, 'child_id': valid_child_ids,
            'type': valid_types, 'ack': valid_ack, 'sub_type': valid_sub_types,
            'payload': valid_payload})
        to_validate = {attr: getattr(self, attr) for attr in schema.schema}
        return schema(to_validate)
1208261
def _AssertDataIsList(key, lst):
  """"""

  # list and tuple are supported.  Not supported are direct strings
  # and dictionary; these indicate too much or two little structure.
  if not isinstance(lst, list) and not isinstance(lst, tuple):
    raise NotAListError('%s must be a list' % key)

  # each list entry must be a string
  for element in lst:
    if not isinstance(element, str):
      raise ElementNotAStringError('Unsupported list element %s found in %s',
                                   (element, lst))
1257440
def get_event_source_status(event_source, lambda_arn, target_function, boto_session, dry=False):
    

    event_source_obj, ctx, funk = get_event_source(event_source, lambda_arn, target_function, boto_session, dry=False)
    return event_source_obj.status(funk)
1049310
def _get_event_source_status(awsclient, evt_source, lambda_arn):
    
    event_source_obj = _get_event_source_obj(awsclient, evt_source)
    return event_source_obj.status(lambda_arn)
380757
def on_assert(self, node):    # ('test', 'msg')
        """"""
        if not self.run(node.test):
            self.raise_exception(node, exc=AssertionError, msg=node.msg)
        return True
277803
def assert_is(self, actual_val, expected_type, failure_message='Expected type to be "{1}," but was "{0}"'):
        
        assertion = lambda: expected_type is actual_val
        self.webdriver_assert(assertion, unicode(failure_message).format(actual_val, expected_type))