From e536bcca30293d2a466749268816f93bae89c531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 3 Sep 2016 20:35:11 +0200 Subject: [PATCH] tests: more qubes.devices tests QubesOS/qubes-issues#2257 --- qubes/tests/devices.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/qubes/tests/devices.py b/qubes/tests/devices.py index 82dd71a8..a851ac83 100644 --- a/qubes/tests/devices.py +++ b/qubes/tests/devices.py @@ -111,6 +111,29 @@ class TC_00_DeviceCollection(qubes.tests.QubesTestCase): with self.assertRaises(LookupError): self.collection.detach(self.device) + def test_013_list_attached_persistent(self): + self.assertEqual(set([]), set(self.collection.attached())) + self.collection.attach(self.device) + self.assertEqual({self.device}, set(self.collection.attached())) + self.assertEqual({self.device}, + set(self.collection.attached(persistent=True))) + self.assertEqual(set([]), + set(self.collection.attached(persistent=False))) + + def test_014_list_attached_non_persistent(self): + self.collection.attach(self.device, persistent=False) + # device-attach event not implemented, so manipulate object manually + self.device.frontend_domain = self.emitter + self.assertEqual({self.device}, + set(self.collection.attached())) + self.assertEqual(set([]), + set(self.collection.attached(persistent=True))) + self.assertEqual({self.device}, + set(self.collection.attached(persistent=False))) + + def test_015_list_available(self): + self.assertEqual({self.device}, set(self.collection)) + class TC_01_DeviceManager(qubes.tests.QubesTestCase): def setUp(self):