mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 16:36:06 +00:00
test: no test connects to a real host
Tests of eight files patched a host's status but not what the page also read, its connection, connection_error or proxy, and so connected for real: over ssh to 10.0.0.9 or over TCP to unroutable addresses (5 to 10 s each until the connect timeout), and to the machine's own libvirt (qemu:///system). A failed host is not tried again for a while, so only the first such test of a process connected, and which one depended on the order. They now patch the connection itself, or what the page reads, and use RFC 5737 addresses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
0d225edda4
commit
9f323d709e
8 changed files with 41 additions and 22 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import json
|
||||
import os
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import PropertyMock, patch
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.shortcuts import reverse
|
||||
|
|
@ -51,11 +51,13 @@ class ComputesTestCase(TestCase):
|
|||
except Exception:
|
||||
self.skipTest("Live libvirt compute host not available")
|
||||
|
||||
def test_index(self):
|
||||
@patch.object(Compute, "connection", new_callable=PropertyMock, return_value=libvirtError("unreachable"))
|
||||
def test_index(self, connection):
|
||||
response = self.client.get(reverse("computes"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_create_update_delete(self):
|
||||
@patch.object(Compute, "connection", new_callable=PropertyMock, return_value=libvirtError("unreachable"))
|
||||
def test_create_update_delete(self, connection):
|
||||
response = self.client.get(reverse("add_socket_host"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue