mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
test: each app keeps its tests in a tests package
131 test modules sat next to the code they test; instances alone had 51 of them beside views.py and utils.py. They move into a tests/ package per app, and the JavaScript checks into webvirtcloud/tests/js. Each non-empty tests.py becomes tests/test_views.py; the empty generated stubs are removed. Imports of the app's own modules become absolute, paths built from __file__ go one level up, the live helper is instances.tests.livetest, and coverage omits */tests/*. The suite discovers the same 960 tests as before.
This commit is contained in:
parent
0906838193
commit
c55f52f025
154 changed files with 27 additions and 39 deletions
0
instances/tests/__init__.py
Normal file
0
instances/tests/__init__.py
Normal file
|
|
@ -8,7 +8,7 @@ import time
|
|||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
GSTFSD = Path(__file__).resolve().parent.parent / "conf" / "daemon" / "gstfsd"
|
||||
GSTFSD = Path(__file__).resolve().parent.parent.parent / "conf" / "daemon" / "gstfsd"
|
||||
|
||||
# A stand-in for libguestfs: the guest's operating systems ("roots", each with
|
||||
# its mountpoints), its files, and what is mounted live in a JSON file.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
"""Live checks that a failed VM creation leaves no volumes behind.
|
||||
|
||||
Runs only with TEST_LIBVIRT_HOST set (see instances/livetest.py).
|
||||
Runs only with TEST_LIBVIRT_HOST set (see instances/tests/livetest.py).
|
||||
"""
|
||||
|
||||
import os
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
Each test asserts the safe behavior. Known unfixed cases are marked
|
||||
expectedFailure; a fix turns them into unexpected successes, which fail
|
||||
the run until the marker is removed. Runs only with
|
||||
TEST_LIBVIRT_HOST set (see instances/livetest.py).
|
||||
TEST_LIBVIRT_HOST set (see instances/tests/livetest.py).
|
||||
"""
|
||||
|
||||
import os
|
||||
|
|
@ -18,8 +18,8 @@ from django.urls import reverse
|
|||
from vrtManager.connection import connection_manager
|
||||
|
||||
from . import livetest
|
||||
from .models import Instance
|
||||
from .utils import refr
|
||||
from instances.models import Instance
|
||||
from instances.utils import refr
|
||||
|
||||
P = livetest.PREFIX
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
QEMU holds a running domain's image, so the size goes through blockResize;
|
||||
the guest and the volume must both see it, and the persistent definition
|
||||
stays as it was. Runs only with TEST_LIBVIRT_HOST set (see instances/livetest.py).
|
||||
stays as it was. Runs only with TEST_LIBVIRT_HOST set (see instances/tests/livetest.py).
|
||||
"""
|
||||
|
||||
import os
|
||||
|
|
@ -6,7 +6,7 @@ with qemu-guest-agent enabled.
|
|||
The tests boot wvc-test VMs from qcow2 overlays in the test pool, so the
|
||||
image itself is only read. They are skipped while a running VM uses the
|
||||
image, since its content would change under the overlays. Runs only with TEST_LIBVIRT_HOST set as well (see
|
||||
instances/livetest.py).
|
||||
instances/tests/livetest.py).
|
||||
"""
|
||||
|
||||
import json
|
||||
|
|
@ -24,8 +24,8 @@ from lxml import etree
|
|||
from vrtManager.connection import connection_manager
|
||||
|
||||
from . import livetest
|
||||
from .models import Instance
|
||||
from .utils import refr
|
||||
from instances.models import Instance
|
||||
from instances.utils import refr
|
||||
|
||||
P = livetest.PREFIX
|
||||
BOOT_TIMEOUT = 300
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Every edit that redefines the domain must start from the persistent
|
||||
definition with secrets (VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE).
|
||||
Runs only with TEST_LIBVIRT_HOST set (see instances/livetest.py).
|
||||
Runs only with TEST_LIBVIRT_HOST set (see instances/tests/livetest.py).
|
||||
"""
|
||||
|
||||
import os
|
||||
|
|
@ -5,7 +5,7 @@ before and after. The edit must show its effect, and once the nodes it is
|
|||
allowed to touch are removed from both sides, the rest of the definition
|
||||
must be identical: unknown elements, secrets and pending changes survive.
|
||||
On a running VM, edits of the persistent definition must leave the live
|
||||
one alone. Runs only with TEST_LIBVIRT_HOST set (see instances/livetest.py).
|
||||
one alone. Runs only with TEST_LIBVIRT_HOST set (see instances/tests/livetest.py).
|
||||
"""
|
||||
|
||||
import os
|
||||
|
|
@ -14,8 +14,8 @@ from vrtManager.create import wvmCreate
|
|||
from vrtManager.util import randomUUID
|
||||
|
||||
from . import livetest
|
||||
from .models import Flavor, Instance
|
||||
from .utils import refr
|
||||
from instances.models import Flavor, Instance
|
||||
from instances.utils import refr
|
||||
|
||||
TEST_COMPUTE_HOST = os.environ.get("TEST_LIBVIRT_HOST", "localhost")
|
||||
TEST_COMPUTE_LOGIN = os.environ.get("TEST_LIBVIRT_LOGIN", "")
|
||||
|
|
@ -15,7 +15,7 @@ from accounts.models import UserInstance, UserSSHKey
|
|||
from computes.models import Compute
|
||||
from instances.models import Instance
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
ROOT = Path(__file__).resolve().parent.parent.parent
|
||||
PAYLOAD = "<script>alert(1)</script>"
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue