2015-01-19 19:02:28 +01:00
|
|
|
# pylint: disable=protected-access,pointless-statement
|
2015-01-19 18:03:23 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# The Qubes OS Project, https://www.qubes-os.org/
|
|
|
|
#
|
|
|
|
# Copyright (C) 2014-2015 Joanna Rutkowska <joanna@invisiblethingslab.com>
|
|
|
|
# Copyright (C) 2014-2015 Wojtek Porczyk <woju@invisiblethingslab.com>
|
|
|
|
#
|
2017-10-12 00:11:50 +02:00
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
2015-01-19 18:03:23 +01:00
|
|
|
#
|
2017-10-12 00:11:50 +02:00
|
|
|
# This library is distributed in the hope that it will be useful,
|
2015-01-19 18:03:23 +01:00
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2017-10-12 00:11:50 +02:00
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
2015-01-19 18:03:23 +01:00
|
|
|
#
|
2017-10-12 00:11:50 +02:00
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, see <https://www.gnu.org/licenses/>.
|
2015-01-19 18:03:23 +01:00
|
|
|
#
|
2014-11-21 16:51:59 +01:00
|
|
|
|
|
|
|
import unittest
|
2016-06-02 22:02:06 +02:00
|
|
|
import uuid
|
2014-11-21 16:51:59 +01:00
|
|
|
|
|
|
|
import lxml.etree
|
|
|
|
|
|
|
|
import qubes
|
2016-05-25 10:29:56 +02:00
|
|
|
import qubes.app
|
2014-12-29 13:11:05 +01:00
|
|
|
import qubes.events
|
2014-12-05 14:58:05 +01:00
|
|
|
import qubes.vm
|
2014-11-21 16:51:59 +01:00
|
|
|
|
2015-01-05 14:41:59 +01:00
|
|
|
import qubes.tests
|
|
|
|
|
2015-01-08 17:29:41 +01:00
|
|
|
class TC_00_Label(qubes.tests.QubesTestCase):
|
2014-12-05 14:58:05 +01:00
|
|
|
def test_000_constructor(self):
|
|
|
|
label = qubes.Label(1, '#cc0000', 'red')
|
|
|
|
|
|
|
|
self.assertEqual(label.index, 1)
|
|
|
|
self.assertEqual(label.color, '#cc0000')
|
|
|
|
self.assertEqual(label.name, 'red')
|
|
|
|
self.assertEqual(label.icon, 'appvm-red')
|
|
|
|
self.assertEqual(label.icon_dispvm, 'dispvm-red')
|
|
|
|
|
|
|
|
def test_001_fromxml(self):
|
2014-11-21 16:51:59 +01:00
|
|
|
xml = lxml.etree.XML('''
|
|
|
|
<qubes version="3">
|
|
|
|
<labels>
|
|
|
|
<label id="label-1" color="#cc0000">red</label>
|
|
|
|
</labels>
|
|
|
|
</qubes>
|
|
|
|
''')
|
|
|
|
|
|
|
|
node = xml.xpath('//label')[0]
|
2014-12-05 14:58:05 +01:00
|
|
|
label = qubes.Label.fromxml(node)
|
2014-11-21 16:51:59 +01:00
|
|
|
|
|
|
|
self.assertEqual(label.index, 1)
|
|
|
|
self.assertEqual(label.color, '#cc0000')
|
|
|
|
self.assertEqual(label.name, 'red')
|
|
|
|
self.assertEqual(label.icon, 'appvm-red')
|
2014-12-05 14:58:05 +01:00
|
|
|
self.assertEqual(label.icon_dispvm, 'dispvm-red')
|
|
|
|
|
2014-11-21 16:51:59 +01:00
|
|
|
|
2015-01-08 17:29:41 +01:00
|
|
|
class TC_10_property(qubes.tests.QubesTestCase):
|
|
|
|
def setUp(self):
|
2017-04-18 10:16:14 +02:00
|
|
|
super().setUp()
|
2015-01-08 17:29:41 +01:00
|
|
|
try:
|
2015-01-20 14:41:19 +01:00
|
|
|
class MyTestHolder(qubes.tests.TestEmitter, qubes.PropertyHolder):
|
2015-01-08 17:29:41 +01:00
|
|
|
testprop1 = qubes.property('testprop1')
|
2016-07-13 21:33:36 +02:00
|
|
|
except: # pylint: disable=bare-except
|
2015-01-20 14:41:19 +01:00
|
|
|
self.skipTest('MyTestHolder class definition failed')
|
|
|
|
self.holder = MyTestHolder(None)
|
2015-01-08 17:29:41 +01:00
|
|
|
|
|
|
|
def test_000_init(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def test_001_hash(self):
|
|
|
|
hash(self.holder.__class__.testprop1)
|
|
|
|
|
|
|
|
def test_002_eq(self):
|
2017-05-29 16:42:40 +02:00
|
|
|
self.assertEqual(qubes.property('testprop2'),
|
2015-01-08 17:29:41 +01:00
|
|
|
qubes.property('testprop2'))
|
|
|
|
|
|
|
|
def test_010_set(self):
|
|
|
|
self.holder.testprop1 = 'testvalue'
|
|
|
|
self.assertEventFired(self.holder, 'property-pre-set:testprop1')
|
|
|
|
self.assertEventFired(self.holder, 'property-set:testprop1')
|
|
|
|
|
|
|
|
def test_020_get(self):
|
|
|
|
self.holder.testprop1 = 'testvalue'
|
|
|
|
self.assertEqual(self.holder.testprop1, 'testvalue')
|
|
|
|
|
|
|
|
def test_021_get_unset(self):
|
|
|
|
with self.assertRaises(AttributeError):
|
|
|
|
self.holder.testprop1
|
|
|
|
|
|
|
|
def test_022_get_default(self):
|
2015-01-20 14:41:19 +01:00
|
|
|
class MyTestHolder(qubes.tests.TestEmitter, qubes.PropertyHolder):
|
2015-01-08 17:29:41 +01:00
|
|
|
testprop1 = qubes.property('testprop1', default='defaultvalue')
|
2015-01-20 14:41:19 +01:00
|
|
|
holder = MyTestHolder(None)
|
2015-01-08 17:29:41 +01:00
|
|
|
|
|
|
|
self.assertEqual(holder.testprop1, 'defaultvalue')
|
|
|
|
|
|
|
|
def test_023_get_default_func(self):
|
2015-01-20 14:41:19 +01:00
|
|
|
class MyTestHolder(qubes.tests.TestEmitter, qubes.PropertyHolder):
|
2015-01-19 17:06:30 +01:00
|
|
|
testprop1 = qubes.property('testprop1',
|
|
|
|
default=(lambda self: 'defaultvalue'))
|
2015-01-20 14:41:19 +01:00
|
|
|
holder = MyTestHolder(None)
|
2015-01-08 17:29:41 +01:00
|
|
|
|
|
|
|
self.assertEqual(holder.testprop1, 'defaultvalue')
|
|
|
|
holder.testprop1 = 'testvalue'
|
|
|
|
self.assertEqual(holder.testprop1, 'testvalue')
|
|
|
|
|
|
|
|
def test_030_set_setter(self):
|
|
|
|
def setter(self2, prop, value):
|
|
|
|
self.assertIs(self2, holder)
|
2015-01-20 14:41:19 +01:00
|
|
|
self.assertIs(prop, MyTestHolder.testprop1)
|
2017-05-29 16:42:40 +02:00
|
|
|
self.assertEqual(value, 'testvalue')
|
2015-01-08 17:29:41 +01:00
|
|
|
return 'settervalue'
|
2016-07-13 21:33:36 +02:00
|
|
|
|
2015-01-20 14:41:19 +01:00
|
|
|
class MyTestHolder(qubes.tests.TestEmitter, qubes.PropertyHolder):
|
2015-01-08 17:29:41 +01:00
|
|
|
testprop1 = qubes.property('testprop1', setter=setter)
|
2015-01-20 14:41:19 +01:00
|
|
|
holder = MyTestHolder(None)
|
2015-01-08 17:29:41 +01:00
|
|
|
|
|
|
|
holder.testprop1 = 'testvalue'
|
|
|
|
self.assertEqual(holder.testprop1, 'settervalue')
|
|
|
|
|
|
|
|
def test_031_set_type(self):
|
2015-01-20 14:41:19 +01:00
|
|
|
class MyTestHolder(qubes.tests.TestEmitter, qubes.PropertyHolder):
|
2015-01-08 17:29:41 +01:00
|
|
|
testprop1 = qubes.property('testprop1', type=int)
|
2015-01-20 14:41:19 +01:00
|
|
|
holder = MyTestHolder(None)
|
2015-01-08 17:29:41 +01:00
|
|
|
|
|
|
|
holder.testprop1 = '5'
|
|
|
|
self.assertEqual(holder.testprop1, 5)
|
|
|
|
self.assertNotEqual(holder.testprop1, '5')
|
|
|
|
|
2015-09-25 21:36:35 +02:00
|
|
|
def test_080_delete(self):
|
2015-01-08 17:29:41 +01:00
|
|
|
self.holder.testprop1 = 'testvalue'
|
|
|
|
try:
|
|
|
|
if self.holder.testprop1 != 'testvalue':
|
|
|
|
self.skipTest('testprop1 value is wrong')
|
|
|
|
except AttributeError:
|
|
|
|
self.skipTest('testprop1 value is wrong')
|
|
|
|
|
|
|
|
del self.holder.testprop1
|
|
|
|
|
|
|
|
with self.assertRaises(AttributeError):
|
2015-01-22 11:24:23 +01:00
|
|
|
self.holder.testprop1
|
2015-01-08 17:29:41 +01:00
|
|
|
|
2015-09-25 21:36:35 +02:00
|
|
|
def test_081_delete_by_assign(self):
|
2015-01-08 17:42:34 +01:00
|
|
|
self.holder.testprop1 = 'testvalue'
|
|
|
|
try:
|
|
|
|
if self.holder.testprop1 != 'testvalue':
|
|
|
|
self.skipTest('testprop1 value is wrong')
|
|
|
|
except AttributeError:
|
|
|
|
self.skipTest('testprop1 value is wrong')
|
|
|
|
|
|
|
|
self.holder.testprop1 = qubes.property.DEFAULT
|
|
|
|
|
|
|
|
with self.assertRaises(AttributeError):
|
2015-01-22 11:24:23 +01:00
|
|
|
self.holder.testprop1
|
2015-01-08 17:42:34 +01:00
|
|
|
|
2015-09-25 21:36:35 +02:00
|
|
|
def test_082_delete_default(self):
|
2015-01-20 14:41:19 +01:00
|
|
|
class MyTestHolder(qubes.tests.TestEmitter, qubes.PropertyHolder):
|
2015-01-08 17:29:41 +01:00
|
|
|
testprop1 = qubes.property('testprop1', default='defaultvalue')
|
2015-01-20 14:41:19 +01:00
|
|
|
holder = MyTestHolder(None)
|
2015-01-08 17:29:41 +01:00
|
|
|
holder.testprop1 = 'testvalue'
|
|
|
|
|
|
|
|
try:
|
|
|
|
if holder.testprop1 != 'testvalue':
|
|
|
|
self.skipTest('testprop1 value is wrong')
|
|
|
|
except AttributeError:
|
|
|
|
self.skipTest('testprop1 value is wrong')
|
|
|
|
|
|
|
|
del holder.testprop1
|
|
|
|
|
|
|
|
self.assertEqual(holder.testprop1, 'defaultvalue')
|
|
|
|
|
2015-09-25 21:36:35 +02:00
|
|
|
def test_090_write_once_set(self):
|
|
|
|
class MyTestHolder(qubes.tests.TestEmitter, qubes.PropertyHolder):
|
|
|
|
testprop1 = qubes.property('testprop1', write_once=True)
|
|
|
|
holder = MyTestHolder(None)
|
|
|
|
|
|
|
|
holder.testprop1 = 'testvalue'
|
|
|
|
|
|
|
|
with self.assertRaises(AttributeError):
|
|
|
|
holder.testprop1 = 'testvalue2'
|
|
|
|
|
|
|
|
def test_091_write_once_delete(self):
|
|
|
|
class MyTestHolder(qubes.tests.TestEmitter, qubes.PropertyHolder):
|
|
|
|
testprop1 = qubes.property('testprop1', write_once=True)
|
|
|
|
holder = MyTestHolder(None)
|
|
|
|
|
|
|
|
holder.testprop1 = 'testvalue'
|
|
|
|
|
|
|
|
with self.assertRaises(AttributeError):
|
|
|
|
del holder.testprop1
|
|
|
|
|
2015-01-08 17:29:41 +01:00
|
|
|
|
2015-01-08 17:32:45 +01:00
|
|
|
class TestHolder(qubes.tests.TestEmitter, qubes.PropertyHolder):
|
2014-12-05 14:58:05 +01:00
|
|
|
testprop1 = qubes.property('testprop1', order=0)
|
|
|
|
testprop2 = qubes.property('testprop2', order=1, save_via_ref=True)
|
|
|
|
testprop3 = qubes.property('testprop3', order=2, default='testdefault')
|
|
|
|
testprop4 = qubes.property('testprop4', order=3)
|
|
|
|
|
|
|
|
|
2015-01-08 17:32:45 +01:00
|
|
|
class TC_20_PropertyHolder(qubes.tests.QubesTestCase):
|
2014-12-05 14:58:05 +01:00
|
|
|
def setUp(self):
|
2017-04-18 10:16:14 +02:00
|
|
|
super().setUp()
|
2014-11-21 16:51:59 +01:00
|
|
|
xml = lxml.etree.XML('''
|
|
|
|
<qubes version="3">
|
2014-12-05 14:58:05 +01:00
|
|
|
<properties>
|
|
|
|
<property name="testprop1">testvalue1</property>
|
|
|
|
<property name="testprop2" ref="testref2" />
|
|
|
|
</properties>
|
2014-11-21 16:51:59 +01:00
|
|
|
</qubes>
|
|
|
|
''')
|
|
|
|
|
2014-12-05 14:58:05 +01:00
|
|
|
self.holder = TestHolder(xml)
|
|
|
|
|
2015-07-03 17:06:24 +02:00
|
|
|
def test_000_property_list(self):
|
|
|
|
self.assertListEqual([p.__name__ for p in self.holder.property_list()],
|
|
|
|
['testprop1', 'testprop2', 'testprop3', 'testprop4'])
|
|
|
|
|
|
|
|
def test_001_property_get_def(self):
|
|
|
|
self.assertIs(
|
|
|
|
self.holder.property_get_def('testprop1'), TestHolder.testprop1)
|
|
|
|
self.assertIs(self.holder.property_get_def(TestHolder.testprop1),
|
|
|
|
TestHolder.testprop1)
|
|
|
|
|
|
|
|
def test_002_load_properties(self):
|
2014-12-05 14:58:05 +01:00
|
|
|
self.holder.load_properties()
|
2015-01-08 17:32:45 +01:00
|
|
|
|
2017-07-25 14:20:20 +02:00
|
|
|
self.assertEventFired(self.holder, 'property-set:testprop1')
|
2015-01-08 17:32:45 +01:00
|
|
|
|
2017-05-29 16:42:40 +02:00
|
|
|
self.assertEqual(self.holder.testprop1, 'testvalue1')
|
|
|
|
self.assertEqual(self.holder.testprop2, 'testref2')
|
|
|
|
self.assertEqual(self.holder.testprop3, 'testdefault')
|
2014-12-05 14:58:05 +01:00
|
|
|
|
|
|
|
with self.assertRaises(AttributeError):
|
|
|
|
self.holder.testprop4
|
|
|
|
|
2015-07-03 17:06:24 +02:00
|
|
|
def test_003_property_is_default(self):
|
|
|
|
self.holder.load_properties()
|
|
|
|
self.assertFalse(self.holder.property_is_default('testprop1'))
|
|
|
|
self.assertFalse(self.holder.property_is_default('testprop2'))
|
|
|
|
self.assertTrue(self.holder.property_is_default('testprop3'))
|
|
|
|
self.assertTrue(self.holder.property_is_default('testprop4'))
|
|
|
|
with self.assertRaises(AttributeError):
|
|
|
|
self.holder.property_is_default('testprop5')
|
|
|
|
|
|
|
|
@unittest.skip('test not implemented')
|
|
|
|
def test_004_property_init(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@unittest.skip('test not implemented')
|
|
|
|
def test_005_clone_properties(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def test_006_xml_properties(self):
|
2014-12-05 14:58:05 +01:00
|
|
|
self.holder.load_properties()
|
|
|
|
|
2015-01-13 15:56:10 +01:00
|
|
|
elements = self.holder.xml_properties()
|
|
|
|
elements_with_defaults = self.holder.xml_properties(with_defaults=True)
|
2014-12-05 14:58:05 +01:00
|
|
|
|
|
|
|
self.assertEqual(len(elements), 2)
|
|
|
|
self.assertEqual(len(elements_with_defaults), 3)
|
|
|
|
|
|
|
|
expected_prop1 = lxml.etree.Element('property', name='testprop1')
|
|
|
|
expected_prop1.text = 'testvalue1'
|
|
|
|
self.assertXMLEqual(elements_with_defaults[0], expected_prop1)
|
|
|
|
|
2015-01-19 17:06:30 +01:00
|
|
|
expected_prop2 = lxml.etree.Element('property',
|
|
|
|
name='testprop2', ref='testref2')
|
2014-12-05 14:58:05 +01:00
|
|
|
self.assertXMLEqual(elements_with_defaults[1], expected_prop2)
|
|
|
|
|
|
|
|
expected_prop3 = lxml.etree.Element('property', name='testprop3')
|
|
|
|
expected_prop3.text = 'testdefault'
|
|
|
|
self.assertXMLEqual(elements_with_defaults[2], expected_prop3)
|
|
|
|
|
2015-07-03 17:06:24 +02:00
|
|
|
@unittest.skip('test not implemented')
|
|
|
|
def test_010_property_require(self):
|
|
|
|
pass
|
2016-04-20 13:41:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
class TestVM(qubes.vm.BaseVM):
|
|
|
|
qid = qubes.property('qid', type=int)
|
|
|
|
name = qubes.property('name')
|
|
|
|
netid = qid
|
2016-06-02 22:02:06 +02:00
|
|
|
uuid = uuid.uuid5(uuid.NAMESPACE_DNS, 'testvm')
|
2016-04-20 13:41:33 +02:00
|
|
|
|
2017-01-18 22:16:46 +01:00
|
|
|
def __lt__(self, other):
|
|
|
|
try:
|
|
|
|
return self.name < other.name
|
|
|
|
except AttributeError:
|
|
|
|
return NotImplemented
|
|
|
|
|
2016-07-13 23:28:02 +02:00
|
|
|
class MockLibvirt(object):
|
|
|
|
def undefine(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
libvirt_domain = MockLibvirt()
|
|
|
|
|
2016-07-13 21:33:12 +02:00
|
|
|
def is_halted(self):
|
2016-07-13 21:33:36 +02:00
|
|
|
return True
|
2016-07-13 21:33:12 +02:00
|
|
|
|
2016-07-13 21:33:36 +02:00
|
|
|
def get_power_state(self):
|
2016-07-13 21:33:12 +02:00
|
|
|
return "Halted"
|
|
|
|
|
2017-01-18 22:16:46 +01:00
|
|
|
|
2016-04-20 13:41:33 +02:00
|
|
|
class TestApp(qubes.tests.TestEmitter):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class TC_30_VMCollection(qubes.tests.QubesTestCase):
|
|
|
|
def setUp(self):
|
2017-04-18 10:16:14 +02:00
|
|
|
super().setUp()
|
2016-04-20 13:41:33 +02:00
|
|
|
self.app = TestApp()
|
2016-05-20 04:22:28 +02:00
|
|
|
self.vms = qubes.app.VMCollection(self.app)
|
2016-04-20 13:41:33 +02:00
|
|
|
|
|
|
|
self.testvm1 = TestVM(None, None, qid=1, name='testvm1')
|
|
|
|
self.testvm2 = TestVM(None, None, qid=2, name='testvm2')
|
2017-09-19 17:01:29 +02:00
|
|
|
self.addCleanup(self.cleanup_testvm)
|
|
|
|
|
|
|
|
def cleanup_testvm(self):
|
|
|
|
self.vms.close()
|
|
|
|
self.testvm1.close()
|
|
|
|
self.testvm2.close()
|
|
|
|
del self.testvm1
|
|
|
|
del self.testvm2
|
|
|
|
del self.vms
|
|
|
|
del self.app
|
2016-04-20 13:41:33 +02:00
|
|
|
|
|
|
|
def test_000_contains(self):
|
|
|
|
self.vms._dict = {1: self.testvm1}
|
|
|
|
|
|
|
|
self.assertIn(1, self.vms)
|
|
|
|
self.assertIn('testvm1', self.vms)
|
|
|
|
self.assertIn(self.testvm1, self.vms)
|
|
|
|
|
|
|
|
self.assertNotIn(2, self.vms)
|
|
|
|
self.assertNotIn('testvm2', self.vms)
|
|
|
|
self.assertNotIn(self.testvm2, self.vms)
|
|
|
|
|
|
|
|
def test_001_getitem(self):
|
|
|
|
self.vms._dict = {1: self.testvm1}
|
|
|
|
|
|
|
|
self.assertIs(self.vms[1], self.testvm1)
|
|
|
|
self.assertIs(self.vms['testvm1'], self.testvm1)
|
|
|
|
self.assertIs(self.vms[self.testvm1], self.testvm1)
|
|
|
|
|
|
|
|
def test_002_add(self):
|
|
|
|
self.vms.add(self.testvm1)
|
|
|
|
self.assertIn(1, self.vms)
|
|
|
|
|
2017-02-21 14:09:06 +01:00
|
|
|
self.assertEventFired(self.app, 'domain-add',
|
|
|
|
kwargs={'vm': self.testvm1})
|
2016-04-20 13:41:33 +02:00
|
|
|
|
|
|
|
with self.assertRaises(TypeError):
|
|
|
|
self.vms.add(object())
|
|
|
|
|
|
|
|
testvm_qid_collision = TestVM(None, None, name='testvm2', qid=1)
|
|
|
|
testvm_name_collision = TestVM(None, None, name='testvm1', qid=2)
|
|
|
|
|
|
|
|
with self.assertRaises(ValueError):
|
|
|
|
self.vms.add(testvm_qid_collision)
|
|
|
|
with self.assertRaises(ValueError):
|
|
|
|
self.vms.add(testvm_name_collision)
|
|
|
|
|
|
|
|
def test_003_qids(self):
|
|
|
|
self.vms.add(self.testvm1)
|
|
|
|
self.vms.add(self.testvm2)
|
|
|
|
|
2017-01-18 22:16:46 +01:00
|
|
|
self.assertCountEqual(self.vms.qids(), [1, 2])
|
|
|
|
self.assertCountEqual(self.vms.keys(), [1, 2])
|
2016-04-20 13:41:33 +02:00
|
|
|
|
|
|
|
def test_004_names(self):
|
|
|
|
self.vms.add(self.testvm1)
|
|
|
|
self.vms.add(self.testvm2)
|
|
|
|
|
2017-01-18 22:16:46 +01:00
|
|
|
self.assertCountEqual(self.vms.names(), ['testvm1', 'testvm2'])
|
2016-04-20 13:41:33 +02:00
|
|
|
|
|
|
|
def test_005_vms(self):
|
|
|
|
self.vms.add(self.testvm1)
|
|
|
|
self.vms.add(self.testvm2)
|
|
|
|
|
2017-01-18 22:16:46 +01:00
|
|
|
self.assertCountEqual(self.vms.vms(), [self.testvm1, self.testvm2])
|
|
|
|
self.assertCountEqual(self.vms.values(), [self.testvm1, self.testvm2])
|
2016-04-20 13:41:33 +02:00
|
|
|
|
|
|
|
def test_006_items(self):
|
|
|
|
self.vms.add(self.testvm1)
|
|
|
|
self.vms.add(self.testvm2)
|
|
|
|
|
2017-01-18 22:16:46 +01:00
|
|
|
self.assertCountEqual(self.vms.items(),
|
2016-04-20 13:41:33 +02:00
|
|
|
[(1, self.testvm1), (2, self.testvm2)])
|
|
|
|
|
|
|
|
def test_007_len(self):
|
|
|
|
self.vms.add(self.testvm1)
|
|
|
|
self.vms.add(self.testvm2)
|
|
|
|
|
|
|
|
self.assertEqual(len(self.vms), 2)
|
|
|
|
|
|
|
|
def test_008_delitem(self):
|
|
|
|
self.vms.add(self.testvm1)
|
|
|
|
self.vms.add(self.testvm2)
|
|
|
|
|
|
|
|
del self.vms['testvm2']
|
|
|
|
|
2017-01-18 22:16:46 +01:00
|
|
|
self.assertCountEqual(self.vms.vms(), [self.testvm1])
|
2017-02-21 14:09:06 +01:00
|
|
|
self.assertEventFired(self.app, 'domain-delete',
|
|
|
|
kwargs={'vm': self.testvm2})
|
2016-04-20 13:41:33 +02:00
|
|
|
|
|
|
|
def test_100_get_new_unused_qid(self):
|
|
|
|
self.vms.add(self.testvm1)
|
|
|
|
self.vms.add(self.testvm2)
|
|
|
|
|
|
|
|
self.vms.get_new_unused_qid()
|
|
|
|
|
|
|
|
def test_101_get_new_unused_netid(self):
|
|
|
|
self.vms.add(self.testvm1)
|
|
|
|
self.vms.add(self.testvm2)
|
|
|
|
|
|
|
|
self.vms.get_new_unused_netid()
|
|
|
|
|
|
|
|
# def test_200_get_vms_based_on(self):
|
|
|
|
# pass
|
|
|
|
|
|
|
|
# def test_201_get_vms_connected_to(self):
|
|
|
|
# pass
|