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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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')
Beispiel #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())