Ejemplo n.º 1
0
  def post(self):
    """Deletes the instance template for the given InstanceTemplateRevision.

    Params:
      key: URL-safe key for a models.InstanceTemplateRevision.
    """
    key = ndb.Key(urlsafe=self.request.get('key'))
    assert key.kind() == 'InstanceTemplateRevision', key
    instance_templates.delete(key)
Ejemplo n.º 2
0
    def post(self):
        """Deletes the instance template for the given InstanceTemplateRevision.

    Params:
      key: URL-safe key for a models.InstanceTemplateRevision.
    """
        key = ndb.Key(urlsafe=self.request.get('key'))
        assert key.kind() == 'InstanceTemplateRevision', key
        instance_templates.delete(key)
Ejemplo n.º 3
0
    def test_url_unspecified(self):
        """Ensures nothing happens when URL is unspecified."""
        key = models.InstanceTemplateRevision(
            key=instance_templates.get_instance_template_revision_key(
                'base-name',
                'revision',
            ),
            project='project',
        ).put()

        instance_templates.delete(key)
        self.failIf(key.get().url)
  def test_url_unspecified(self):
    """Ensures nothing happens when URL is unspecified."""
    key = models.InstanceTemplateRevision(
        key=instance_templates.get_instance_template_revision_key(
            'base-name',
            'revision',
        ),
        project='project',
    ).put()

    instance_templates.delete(key)
    self.failIf(key.get().url)
  def test_url_not_found(self):
    """Ensures URL is updated when the instance template is not found."""
    def json_request(url, *args, **kwargs):
      raise net.Error('', 404, '')
    self.mock(instance_templates.net, 'json_request', json_request)

    key = models.InstanceTemplateRevision(
        key=instance_templates.get_instance_template_revision_key(
            'base-name',
            'revision',
        ),
        project='project',
        url='url',
    ).put()

    instance_templates.delete(key)
    self.failIf(key.get().url)
  def test_deletes(self):
    """Ensures an instance template is deleted."""
    def json_request(url, *args, **kwargs):
      return {'targetLink': url}
    self.mock(instance_templates.net, 'json_request', json_request)

    key = models.InstanceTemplateRevision(
        key=instance_templates.get_instance_template_revision_key(
            'base-name',
            'revision',
        ),
        project='project',
        url='url',
    ).put()

    instance_templates.delete(key)
    self.failIf(key.get().url)
Ejemplo n.º 7
0
    def test_url_not_found(self):
        """Ensures URL is updated when the instance template is not found."""
        def json_request(url, *args, **kwargs):
            raise net.Error('', 404, '')

        self.mock(instance_templates.net, 'json_request', json_request)

        key = models.InstanceTemplateRevision(
            key=instance_templates.get_instance_template_revision_key(
                'base-name',
                'revision',
            ),
            project='project',
            url='url',
        ).put()

        instance_templates.delete(key)
        self.failIf(key.get().url)
Ejemplo n.º 8
0
    def test_deletes(self):
        """Ensures an instance template is deleted."""
        def json_request(url, *args, **kwargs):
            return {'targetLink': url}

        self.mock(instance_templates.net, 'json_request', json_request)

        key = models.InstanceTemplateRevision(
            key=instance_templates.get_instance_template_revision_key(
                'base-name',
                'revision',
            ),
            project='project',
            url='url',
        ).put()

        instance_templates.delete(key)
        self.failIf(key.get().url)
Ejemplo n.º 9
0
    def test_url_mismatch(self):
        """Ensures nothing happens when the targetLink doesn't match."""
        def json_request(*args, **kwargs):
            return {'targetLink': 'mismatch'}

        self.mock(instance_templates.net, 'json_request', json_request)

        key = models.InstanceTemplateRevision(
            key=instance_templates.get_instance_template_revision_key(
                'base-name',
                'revision',
            ),
            project='project',
            url='url',
        ).put()

        instance_templates.delete(key)
        self.assertEqual(key.get().url, 'url')
Ejemplo n.º 10
0
    def test_entity_doesnt_exist(self):
        """Ensures nothing happens when the entity doesn't exist."""
        key = ndb.Key(models.InstanceTemplateRevision, 'fake-key')

        instance_templates.delete(key)
        self.failIf(key.get())
  def test_entity_doesnt_exist(self):
    """Ensures nothing happens when the entity doesn't exist."""
    key = ndb.Key(models.InstanceTemplateRevision, 'fake-key')

    instance_templates.delete(key)
    self.failIf(key.get())