コード例 #1
0
  def test05_destroy_vm(self):
    """Happy path test to verify destruction of VM instances."""

    # Construct mock return object.
    json_body = '{"ok": true}'

    resp = _HttpResponse(200, json_body)

    # Patch
    with patch.object(service, '_make_request', return_value=resp) as mock_func:
      service.destroy_vm(self.vmpooler_url, self.hostname, self.auth_token)
コード例 #2
0
    def test05_destroy_vm(self):
        """Happy path test to verify destruction of VM instances."""

        # Construct mock return object.
        json_body = '{"ok": true}'

        resp = _HttpResponse(200, json_body)

        # Patch
        with patch.object(service, '_make_request',
                          return_value=resp) as mock_func:
            service.destroy_vm(self.vmpooler_hostname, self.hostname,
                               self.auth_token)
コード例 #3
0
  def test06_destroy_vm_neg(self):
    """Negative test case for attempting to destroy non-existent VM instance."""

    # Construct mock return object.
    json_body = '{"ok": false}'

    resp = _HttpResponse(404, json_body)

    # Patch
    with patch.object(service, '_make_request', return_value=resp) as mock_func:
      with self.assertRaises(RuntimeError) as cm:
        service.destroy_vm(self.vmpooler_url, self.hostname, self.auth_token)

        excep = cm.exception

        self.assertEqual(excep.msg, 'The VM is already destroyed or wrong VM name provided!')
コード例 #4
0
    def test06_destroy_vm_neg(self):
        """Negative test case for attempting to destroy non-existent VM instance."""

        # Construct mock return object.
        json_body = '{"ok": false}'

        resp = _HttpResponse(404, json_body)

        # Patch
        with patch.object(service, '_make_request',
                          return_value=resp) as mock_func:
            with self.assertRaises(RuntimeError) as cm:
                service.destroy_vm(self.vmpooler_hostname, self.hostname,
                                   self.auth_token)

                excep = cm.exception

                self.assertEqual(
                    excep.msg,
                    'The VM is already destroyed or wrong VM name provided!')