...
 
Commits (2)
......@@ -29,7 +29,7 @@ Running from git repository
```
* Before posting a patch, you should run tests:
* Before posting a patch, you should run tests and perform syntax-checking:
```
make check
......@@ -37,6 +37,12 @@ Running from git repository
The test tool requires python3, python3-pytest and python3-dbus.
```
make syntax-check
```
To run this flake8 package is required.
* To run libvirt-dbus directly from the build dir without installing it
use the run script:
......
......@@ -42,3 +42,10 @@ gen-AUTHORS:
mv -f $(distdir)/AUTHORS-tmp $(distdir)/AUTHORS && \
rm -f all.list maint.list contrib.list; \
fi
# E501: (line too long) warning is ignored.
.PHONY: flake8
flake8:
flake8 --show-source --ignore=E501
syntax-check: flake8
......@@ -107,7 +107,6 @@ class BaseTestClass():
path = interface_obj.StorageVolCreateXML(xmldata.minimal_storage_vol_xml, 0)
yield path
def get_test_domain(self):
path = self.connect.ListDomains(0)[0]
obj = self.bus.get_object('org.libvirt', path)
......@@ -196,7 +195,7 @@ class DomainEventStoppedDetailType(IntEnum):
SHUTDOWN = 0
DESTROYED = 1
CRASHED = 2
MIGRATED = 3
MIGRATED = 3
SAVED = 4
FAILED = 5
FROM_SNAPSHOT = 6
......@@ -205,9 +204,9 @@ class DomainEventStoppedDetailType(IntEnum):
class DomainEventSuspendedDetailType(IntEnum):
PAUSED = 0
MIGRATED = 1
MIGRATED = 1
IOERROR = 2
WATCHDOG = 3
WATCHDOG = 3
RESTORED = 4
FROM_SNAPSHOT = 5
API_ERROR = 6
......@@ -240,10 +239,12 @@ class NetworkEvent(IntEnum):
STARTED = 2
STOPPED = 3
class NodeDeviceEvent(IntEnum):
CREATED = 0
DELETED = 1
class StoragePoolBuildFlags(IntEnum):
NEW = 0
REPAIR = 1
......
......@@ -96,7 +96,7 @@ class TestConnect(libvirttest.BaseTestClass):
def test_connect_interface_lookup_by_property(self, lookup_method_name, lookup_item, interface_create):
"""Parameterized test for all InterfaceLookupBy* API calls of Connect interface
"""
original_path,_ = interface_create
original_path, _ = interface_create
obj = self.bus.get_object('org.libvirt', original_path)
prop = obj.Get('org.libvirt.Interface', lookup_item, dbus_interface=dbus.PROPERTIES_IFACE)
path = getattr(self.connect, lookup_method_name)(prop)
......
......@@ -5,6 +5,7 @@ import libvirttest
DBUS_EXCEPTION_MISSING_FUNCTION = 'this function is not supported by the connection driver'
class TestDomain(libvirttest.BaseTestClass):
def test_api(self):
obj, domain = self.get_test_domain()
......@@ -153,8 +154,8 @@ class TestDomain(libvirttest.BaseTestClass):
def test_domain_vcpu_pin_info(self):
obj, domain = self.get_test_domain()
pinInfo_expected = [
[ True, True, True, True, True, True, True, True ],
[ True, True, True, True, True, True, True, True ]
[True, True, True, True, True, True, True, True],
[True, True, True, True, True, True, True, True]
]
pinInfo = domain.GetVcpuPinInfo(0)
assert pinInfo == pinInfo_expected
......
......@@ -4,38 +4,40 @@ import dbus
import libvirttest
import pytest
@pytest.mark.usefixtures("interface_create")
class TestInterface(libvirttest.BaseTestClass):
""" Tests for methods and properties of the Interface interface
"""
def test_interface_undefine(self, interface_create):
_,interface_obj = interface_create
_, interface_obj = interface_create
interface_obj.Destroy(0)
interface_obj.Undefine()
def test_interface_destroy(self, interface_create):
_,interface_obj = interface_create
_, interface_obj = interface_create
interface_obj.Destroy(0)
def test_interface_create(self, interface_create):
_,interface_obj = interface_create
_, interface_obj = interface_create
interface_obj.Destroy(0)
interface_obj.Create(0)
def test_interface_get_xml_description(self, interface_create):
_,interface_obj = interface_create
_, interface_obj = interface_create
assert isinstance(interface_obj.GetXMLDesc(0), dbus.String)
def test_interface_properties_type(self, interface_create):
""" Ensure correct return type for Interface properties
"""
test_interface_path,_ = interface_create
test_interface_path, _ = interface_create
obj = self.bus.get_object('org.libvirt', test_interface_path)
props = obj.GetAll('org.libvirt.Interface', dbus_interface=dbus.PROPERTIES_IFACE)
assert isinstance(props['Name'], dbus.String)
assert isinstance(props['MAC'], dbus.String)
assert isinstance(props['Active'], dbus.Boolean)
if __name__ == '__main__':
libvirttest.run()
......@@ -25,7 +25,7 @@ class TestNetwork(libvirttest.BaseTestClass):
assert isinstance(props['UUID'], dbus.String)
def test_network_autostart(self):
_,test_network = self.get_test_network()
_, test_network = self.get_test_network()
interface_obj = dbus.Interface(test_network, 'org.libvirt.Network')
autostart_expected = True
interface_obj.Set('org.libvirt.Network', 'Autostart', autostart_expected, dbus_interface=dbus.PROPERTIES_IFACE)
......@@ -41,7 +41,7 @@ class TestNetwork(libvirttest.BaseTestClass):
self.connect.connect_to_signal('NetworkEvent', domain_started)
_,test_network = self.get_test_network()
_, test_network = self.get_test_network()
interface_obj = dbus.Interface(test_network, 'org.libvirt.Network')
interface_obj.Destroy()
interface_obj.Create()
......@@ -64,7 +64,7 @@ class TestNetwork(libvirttest.BaseTestClass):
self.main_loop()
def test_network_get_xml_description(self):
_,test_network = self.get_test_network()
_, test_network = self.get_test_network()
interface_obj = dbus.Interface(test_network, 'org.libvirt.Network')
assert isinstance(interface_obj.GetXMLDesc(0), dbus.String)
......@@ -77,7 +77,7 @@ class TestNetwork(libvirttest.BaseTestClass):
self.connect.connect_to_signal('NetworkEvent', domain_undefined)
_,test_network = self.get_test_network()
_, test_network = self.get_test_network()
interface_obj = dbus.Interface(test_network, 'org.libvirt.Network')
interface_obj.Destroy()
interface_obj.Undefine()
......
......@@ -4,6 +4,7 @@ import dbus
import libvirttest
import pytest
class TestStoragePool(libvirttest.BaseTestClass):
def test_storage_pool_autostart(self):
_, test_storage_pool = self.get_test_storage_pool()
......