commit 7e0c7e344422531ff4ddea790bdb301c09e6c5c6
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Tue Sep 9 16:18:27 2014 +0200
tests: add vdsm test
tests/test_vdsm.py | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_vdsm.py b/tests/test_vdsm.py
new file mode 100644
index 0000000..e14dfec
--- /dev/null
+++ b/tests/test_vdsm.py
@@ -0,0 +1,60 @@
+"""
+Test of VDSM virtualization backend.
+
+Copyright (C) 2014 Radek Novacek <rnovacek(a)redhat.com>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+"""
+
+import logging
+import urllib2
+import suds
+from mock import MagicMock
+
+from base import TestBase
+from config import Config
+from virt.vdsm import Vdsm
+from virt import VirtError
+import xmlrpclib
+
+
+class TestEsx(TestBase):
+ def setUp(self):
+ config = Config('test', 'vdsm')
+
+ def fakeSecureConnect(self):
+ return MagicMock()
+ Vdsm._secureConnect = fakeSecureConnect
+ self.vdsm = Vdsm(self.logger, config)
+
+ def test_connect(self):
+ self.vdsm.server.list = MagicMock()
+ self.vdsm.server.list.return_value = {
+ 'status': {
+ 'code': 0
+ },
+ 'vmList': [
+ {
+ 'vmId': '1'
+ }, {
+ 'vmId': '2'
+ }, {
+ 'vmId': '3'
+ }
+ ]
+ }
+ domains = self.vdsm.listDomains()
+ self.assertEquals(domains, ['1', '2', '3'])
+ self.vdsm.server.list.assert_called_once()
Show replies by date