Example #1
0
 def _pre_put_hook(self):
     """Adds automatic tags."""
     super(TaskRequest, self)._pre_put_hook()
     self.properties._pre_put_hook()
     if self.properties.is_terminate:
         if not self.priority == 0:
             raise datastore_errors.BadValueError(
                 'terminate request must be priority 0')
     elif self.priority == 0:
         raise datastore_errors.BadValueError(
             'priority 0 can only be used for terminate request')
     self.tags.append('priority:%s' % self.priority)
     self.tags.append('user:%s' % self.user)
     for key, value in self.properties.dimensions.iteritems():
         self.tags.append('%s:%s' % (key, value))
     self.tags = sorted(set(self.tags))
     if (self.pubsub_topic and
             not pubsub.validate_full_name(self.pubsub_topic, 'topics')):
         raise datastore_errors.BadValueError('bad pubsub topic name - %s' %
                                              self.pubsub_topic)
     if self.pubsub_auth_token and not self.pubsub_topic:
         raise datastore_errors.BadValueError(
             'pubsub_auth_token requires pubsub_topic')
     if self.pubsub_userdata and not self.pubsub_topic:
         raise datastore_errors.BadValueError(
             'pubsub_userdata requires pubsub_topic')
Example #2
0
  def _pre_put_hook(self):
    """Adds automatic tags."""
    super(TaskRequest, self)._pre_put_hook()
    self.properties._pre_put_hook()
    if self.properties.is_terminate:
      if not self.priority == 0:
        raise datastore_errors.BadValueError(
            'terminate request must be priority 0')
    elif self.priority == 0:
      raise datastore_errors.BadValueError(
          'priority 0 can only be used for terminate request')

    if (self.pubsub_topic and
        not pubsub.validate_full_name(self.pubsub_topic, 'topics')):
      raise datastore_errors.BadValueError(
          'bad pubsub topic name - %s' % self.pubsub_topic)
    if self.pubsub_auth_token and not self.pubsub_topic:
      raise datastore_errors.BadValueError(
          'pubsub_auth_token requires pubsub_topic')
    if self.pubsub_userdata and not self.pubsub_topic:
      raise datastore_errors.BadValueError(
          'pubsub_userdata requires pubsub_topic')

    self.tags.append('priority:%s' % self.priority)
    self.tags.append('user:%s' % self.user)
    for key, value in self.properties.dimensions.iteritems():
      self.tags.append('%s:%s' % (key, value))
    self.tags = sorted(set(self.tags))
Example #3
0
 def test_validate_full_name(self):
     self.assertTrue(pubsub.validate_full_name("projects/abc/topics/def", "topics"))
     self.assertFalse(pubsub.validate_full_name("projects/abc/topics", "topics"))
     self.assertFalse(pubsub.validate_full_name("what/abc/topics/def", "topics"))
     self.assertFalse(pubsub.validate_full_name("projects//topics/def", "topics"))
     self.assertFalse(pubsub.validate_full_name("projects/abc/nottopics/def", "topics"))
     self.assertFalse(pubsub.validate_full_name("projects/abc/topics/1topic", "topics"))
Example #4
0
 def test_validate_full_name(self):
   self.assertTrue(
       pubsub.validate_full_name('projects/abc/topics/def', 'topics'))
   self.assertFalse(
       pubsub.validate_full_name('projects/abc/topics', 'topics'))
   self.assertFalse(
       pubsub.validate_full_name('what/abc/topics/def', 'topics'))
   self.assertFalse(
       pubsub.validate_full_name('projects//topics/def', 'topics'))
   self.assertFalse(
       pubsub.validate_full_name('projects/abc/nottopics/def', 'topics'))
   self.assertFalse(
       pubsub.validate_full_name('projects/abc/topics/1topic', 'topics'))
Example #5
0
  def _pre_put_hook(self):
    """Adds automatic tags."""
    super(TaskRequest, self)._pre_put_hook()
    self.properties._pre_put_hook()
    if self.properties.is_terminate:
      if not self.priority == 0:
        raise datastore_errors.BadValueError(
            'terminate request must be priority 0')
    elif self.priority == 0:
      raise datastore_errors.BadValueError(
          'priority 0 can only be used for terminate request')

    if (self.pubsub_topic and
        not pubsub.validate_full_name(self.pubsub_topic, 'topics')):
      raise datastore_errors.BadValueError(
          'bad pubsub topic name - %s' % self.pubsub_topic)
    if self.pubsub_auth_token and not self.pubsub_topic:
      raise datastore_errors.BadValueError(
          'pubsub_auth_token requires pubsub_topic')
    if self.pubsub_userdata and not self.pubsub_topic:
      raise datastore_errors.BadValueError(
          'pubsub_userdata requires pubsub_topic')