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,3 +1,5 @@
|
|||
from unittest.mock import PropertyMock, patch
|
||||
|
||||
from appsettings.models import AppSettings
|
||||
from appsettings.settings import app_settings
|
||||
from computes.models import Compute
|
||||
|
|
@ -7,6 +9,7 @@ from django.contrib.auth.models import Permission
|
|||
from django.shortcuts import reverse
|
||||
from django.test import Client, RequestFactory, TestCase, override_settings
|
||||
from instances.models import Instance
|
||||
from libvirt import libvirtError
|
||||
|
||||
|
||||
from accounts.forms import UserInstanceForm, UserSSHKeyForm
|
||||
|
|
@ -36,6 +39,10 @@ class AccountsTestCase(TestCase):
|
|||
)
|
||||
|
||||
def setUp(self):
|
||||
# the pages read no host: its compute is not there
|
||||
down = patch.object(Compute, "connection", new_callable=PropertyMock, return_value=libvirtError("unreachable"))
|
||||
down.start()
|
||||
self.addCleanup(down.stop)
|
||||
self.client.force_login(self.admin_user)
|
||||
permission = Permission.objects.get(codename="change_password")
|
||||
self.test_user.user_permissions.add(permission)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue