mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 11:16:47 +00:00
- 25 vrtManager test modules configured settings themselves when Django had none (MAC_OUI, and in test_network_ip a fake django module): under manage.py test settings are always configured, so it never ran. - webvirtcloud/tests/test_common_tags.py tested no tag: it fetched an unknown URL, as test_error_pages and test_logging already do. - .gitignore covers the parallel runs' test_db_N.sqlite3 files too.
42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
"""Values from requests do not change the XPath queries they are used in."""
|
|
|
|
import unittest
|
|
from unittest.mock import Mock
|
|
|
|
from vrtManager.connection import wvmConnect
|
|
from vrtManager.network import wvmNetwork
|
|
|
|
CAPS = """<capabilities><guest><arch name='x86_64'><wordsize>64</wordsize><emulator>/usr/bin/qemu-x86</emulator>
|
|
<machine canonical='pc-q35'>q35</machine></arch>
|
|
<arch name='aarch64'><emulator>/usr/bin/qemu-arm</emulator><machine>virt</machine></arch></guest></capabilities>"""
|
|
|
|
class FakeConn:
|
|
def __init__(self):
|
|
self.defined = None
|
|
|
|
def networkDefineXML(self, xml):
|
|
self.defined = xml
|
|
|
|
|
|
class XPathValueTests(unittest.TestCase):
|
|
def setUp(self):
|
|
self.conn = wvmConnect.__new__(wvmConnect)
|
|
self.conn.get_cap_xml = lambda: CAPS
|
|
|
|
def test_arch_lookups(self):
|
|
self.assertEqual(self.conn.get_emulator("x86_64"), "/usr/bin/qemu-x86")
|
|
self.assertEqual(self.conn.get_machine_types("aarch64"), ["virt"])
|
|
injected = "nope' or '1'='1"
|
|
self.assertIsNone(self.conn.get_emulator(injected))
|
|
self.assertEqual(self.conn.get_machine_types(injected), [])
|
|
self.assertEqual(self.conn.get_capabilities(injected), {})
|
|
|
|
def test_qos_direction_must_be_known(self):
|
|
net = wvmNetwork.__new__(wvmNetwork)
|
|
net.wvm = FakeConn()
|
|
net.net = Mock(**{"XMLDesc.return_value": "<network><bandwidth><inbound average='1'/><outbound average='2'/></bandwidth></network>"})
|
|
with self.assertRaises(ValueError):
|
|
net.unset_qos("*")
|
|
net.unset_qos("inbound")
|
|
self.assertNotIn("inbound", net.wvm.defined)
|
|
self.assertIn("outbound", net.wvm.defined)
|