Пример #1
0
 def test_delete_and_verify_verify_404(self):
     """
     :func:`delete_and_verify` gets server details after successful delete
     and succeeds if get server details returns 404
     """
     eff = delete_and_verify('sid')
     eff = resolve_effect(
         eff, service_request_error_response(APIError(204, {})),
         is_error=True)
     r = resolve_effect(eff, (StubResponse(404, {}), {"itemNotFound": {}}))
     self.assertIsNone(r)
Пример #2
0
 def test_delete_and_verify_del_fails(self):
     """
     :func:`delete_and_verify` fails if delete server fails
     """
     eff = delete_and_verify('sid')
     self.assertRaises(
         APIError,
         resolve_effect,
         eff,
         service_request_error_response(APIError(500, '')),
         is_error=True)
Пример #3
0
 def test_delete_and_verify_del_404(self):
     """
     :func:`delete_and_verify` invokes server delete and succeeds on 404
     """
     eff = delete_and_verify('sid')
     self.assertEqual(
         eff.intent,
         service_request(
             ServiceType.CLOUD_SERVERS, 'DELETE', 'servers/sid',
             success_pred=has_code(404)).intent)
     self.assertEqual(resolve_effect(eff, (ANY, {})), (ANY, {}))
Пример #4
0
 def test_delete_and_verify_del_fails_non_apierror(self):
     """
     :func:`delete_and_verify` fails if delete server fails with error
     other than APIError
     """
     eff = delete_and_verify('sid')
     self.assertRaises(
         ValueError,
         resolve_effect,
         eff,
         service_request_error_response(ValueError('meh')),
         is_error=True)
Пример #5
0
 def test_delete_and_verify_verify_unexpectedstatus(self):
     """
     :func:`delete_and_verify` raises `UnexpectedServerStatus` error
     if server status returned after deleting is not "deleting"
     """
     eff = delete_and_verify('sid')
     eff = resolve_effect(
         eff, service_request_error_response(APIError(204, {})),
         is_error=True)
     self.assertRaises(
         UnexpectedServerStatus,
         resolve_effect,
         eff,
         (StubResponse(200, {}),
          {'server': {"OS-EXT-STS:task_state": 'bad'}})
     )
Пример #6
0
    def test_delete_and_verify_verifies(self):
        """
        :func:`delete_and_verify` verifies if the server task_state has changed
        to "deleting" after successful delete server call and succeeds if that
        has happened. The details call succeeds if it returns 404
        """
        eff = delete_and_verify('sid')
        eff = resolve_effect(
            eff, service_request_error_response(APIError(204, {})),
            is_error=True)

        self.assertEqual(
            eff.intent,
            service_request(
                ServiceType.CLOUD_SERVERS, 'GET', 'servers/sid',
                success_pred=has_code(200, 404)).intent)
        r = resolve_effect(
            eff,
            (StubResponse(200, {}),
             {'server': {"OS-EXT-STS:task_state": 'deleting'}}))
        self.assertIsNone(r)