Ejemplo n.º 1
0
    def test_get_not_found(self):
        self.res.get.side_effect = exceptions.NotFoundException(
            message="test", http_status=404)

        self.assertRaisesRegexp(
            exceptions.ResourceNotFound,
            "No %s found for %s" % (RetrieveableResource.__name__, self.res),
            self.sot._get, RetrieveableResource, self.res)
Ejemplo n.º 2
0
    def test_delete_ResourceNotFound(self):
        self.res.delete.side_effect = exceptions.NotFoundException(
            message="test", http_status=404)

        self.assertRaisesRegexp(
            exceptions.ResourceNotFound,
            "No %s found for %s" % (DeleteableResource.__name__, self.res),
            self.sot._delete, DeleteableResource, self.res,
            ignore_missing=True)
Ejemplo n.º 3
0
    def test_get(self, mock_get):
        sess = mock.Mock()
        sot = stack.Stack(**FAKE)
        deleted_stack = mock.Mock(id=FAKE_ID, status='DELETE_COMPLETE')
        normal_stack = mock.Mock(status='CREATE_COMPLETE')
        mock_get.side_effect = [
            normal_stack,
            exceptions.NotFoundException(message='oops'),
            deleted_stack,
        ]

        self.assertEqual(normal_stack, sot.get(sess))
        ex = self.assertRaises(exceptions.NotFoundException, sot.get, sess)
        self.assertEqual('NotFoundException: oops', six.text_type(ex))
        ex = self.assertRaises(exceptions.NotFoundException, sot.get, sess)
        self.assertEqual('NotFoundException: No stack found for %s' % FAKE_ID,
                         six.text_type(ex))
Ejemplo n.º 4
0
    def test_delete_ignore_missing(self):
        self.res.delete.side_effect = exceptions.NotFoundException(
            message="test", http_status=404)

        rv = self.sot._delete(DeleteableResource, self.fake_id)
        self.assertIsNone(rv)
Ejemplo n.º 5
0
 def get(self, session, requires_id=True):
     stk = super(Stack, self).get(session, requires_id=requires_id)
     if stk and stk.status in ['DELETE_COMPLETE', 'ADOPT_COMPLETE']:
         raise exceptions.NotFoundException("No stack found for %s" %
                                            stk.id)
     return stk