From nobody Wed Jan 15 13:36:51 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) client-ip=66.187.230.42; envelope-from=kimchi-devel-bounces@ovirt.org; helo=lists.ovirt.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) smtp.mailfrom=kimchi-devel-bounces@ovirt.org; Return-Path: Received: from lists.ovirt.org (lists.phx.ovirt.org [66.187.230.42]) by mx.zohomail.com with SMTPS id 1486605786838735.5769378900096; Wed, 8 Feb 2017 18:03:06 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id C630C8205CD; Thu, 9 Feb 2017 02:03:05 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id 4E60682059B for ; Thu, 9 Feb 2017 02:02:24 +0000 (UTC) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v191wVdk108752 for ; Wed, 8 Feb 2017 21:02:23 -0500 Received: from e24smtp02.br.ibm.com (e24smtp02.br.ibm.com [32.104.18.86]) by mx0b-001b2d01.pphosted.com with ESMTP id 28gcrj4tre-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 08 Feb 2017 21:02:23 -0500 Received: from localhost by e24smtp02.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 9 Feb 2017 00:02:20 -0200 Received: from d24dlp01.br.ibm.com (9.18.248.204) by e24smtp02.br.ibm.com (10.172.0.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 9 Feb 2017 00:02:18 -0200 Received: from d24relay01.br.ibm.com (d24relay01.br.ibm.com [9.8.31.16]) by d24dlp01.br.ibm.com (Postfix) with ESMTP id 3AA41352005F for ; Wed, 8 Feb 2017 21:01:45 -0500 (EST) Received: from d24av05.br.ibm.com (d24av05.br.ibm.com [9.18.232.44]) by d24relay01.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1922I124784196 for ; Thu, 9 Feb 2017 00:02:18 -0200 Received: from d24av05.br.ibm.com (localhost [127.0.0.1]) by d24av05.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v1922I56015796 for ; Thu, 9 Feb 2017 00:02:18 -0200 Received: from alinefm-TP440.ibmmodules.com ([9.80.222.200]) by d24av05.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v1922D8G015772 for ; Thu, 9 Feb 2017 00:02:17 -0200 X-Original-To: kimchi-devel@ovirt.org From: Aline Manera To: Kimchi Devel Date: Thu, 9 Feb 2017 00:01:58 -0200 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170209020202.17425-1-alinefm@linux.vnet.ibm.com> References: <20170209020202.17425-1-alinefm@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020902-0020-0000-0000-000002857447 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020902-0021-0000-0000-0000309F95C1 Message-Id: <20170209020202.17425-3-alinefm@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-09_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702090015 Subject: [Kimchi-devel] [PATCH] [Kimchi 2/6] Update run_server() calls to do not pass model instance X-BeenThere: kimchi-devel@ovirt.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: kimchi-devel-bounces@ovirt.org Errors-To: kimchi-devel-bounces@ovirt.org X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The model instance will be gotten from cherrypy when needed. Signed-off-by: Aline Manera --- tests/test_authorization.py | 10 ++++------ tests/test_host.py | 15 +++------------ tests/test_livemigration.py | 6 +----- tests/test_mock_network.py | 10 ++++------ tests/test_mock_storagepool.py | 12 ++++-------- tests/test_mock_storagevolume.py | 11 ++++------- tests/test_mockmodel.py | 8 +++----- tests/test_model_network.py | 18 +++++++++++------- tests/test_model_storagepool.py | 18 ++++++++++-------- tests/test_model_storagevolume.py | 18 +++++++++++------- tests/test_rest.py | 7 +++---- tests/test_template.py | 9 ++++----- 12 files changed, 62 insertions(+), 80 deletions(-) diff --git a/tests/test_authorization.py b/tests/test_authorization.py index 565f446..b67d8d6 100644 --- a/tests/test_authorization.py +++ b/tests/test_authorization.py @@ -1,7 +1,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2014-2016 +# Copyright IBM Corp, 2014-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -17,6 +17,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA =20 +import cherrypy import json import os import unittest @@ -25,8 +26,6 @@ from functools import partial from tests.utils import get_fake_user, patch_auth from tests.utils import request, run_server, wait_task =20 -from wok.plugins.kimchi import mockmodel - from iso_gen import construct_fake_iso =20 =20 @@ -39,8 +38,8 @@ def setUpModule(): global test_server, model =20 patch_auth(sudo=3DFalse) - model =3D mockmodel.MockModel('/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 # Create fake ISO to do the tests construct_fake_iso(fake_iso, True, '12.04', 'ubuntu') @@ -48,7 +47,6 @@ def setUpModule(): =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') os.unlink(fake_iso) =20 =20 diff --git a/tests/test_host.py b/tests/test_host.py index 1ee3368..6db6839 100644 --- a/tests/test_host.py +++ b/tests/test_host.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -19,33 +19,24 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA =20 import json -import os -import tempfile import unittest from functools import partial =20 from tests.utils import patch_auth, request, run_server =20 -from wok.plugins.kimchi.mockmodel import MockModel - =20 test_server =3D None -model =3D None -tmpfile =3D None =20 =20 def setUpModule(): - global test_server, model, tmpfile + global test_server =20 patch_auth() - tmpfile =3D tempfile.mktemp() - model =3D MockModel(tmpfile) - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) =20 =20 def tearDownModule(): test_server.stop() - os.unlink(tmpfile) =20 =20 class HostTests(unittest.TestCase): diff --git a/tests/test_livemigration.py b/tests/test_livemigration.py index 7d49dc1..90fdaa1 100644 --- a/tests/test_livemigration.py +++ b/tests/test_livemigration.py @@ -407,12 +407,8 @@ class LiveMigrationTests(unittest.TestCase): 'not possible to test a live migration') def test_vm_livemigrate_persistent_API(self): patch_auth() - - inst =3D model.Model(libvirt_uri=3D'qemu:///system', - objstore_loc=3Dself.tmp_store) - with RollbackContext() as rollback: - test_server =3D run_server(test_mode=3DTrue, model=3Dinst) + test_server =3D run_server() rollback.prependDefer(test_server.stop) =20 self.request =3D partial(request) diff --git a/tests/test_mock_network.py b/tests/test_mock_network.py index 48e5557..c1e875d 100644 --- a/tests/test_mock_network.py +++ b/tests/test_mock_network.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,14 +18,13 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA =20 +import cherrypy import json -import os import unittest from functools import partial =20 from tests.utils import patch_auth, request, run_server =20 -from wok.plugins.kimchi.mockmodel import MockModel from wok.plugins.kimchi.model.featuretests import FeatureTests =20 from test_model_network import _do_network_test @@ -39,13 +38,12 @@ def setUpModule(): global test_server, model =20 patch_auth() - model =3D MockModel('/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') =20 =20 class MockNetworkTests(unittest.TestCase): diff --git a/tests/test_mock_storagepool.py b/tests/test_mock_storagepool.py index 5c152e4..f584382 100644 --- a/tests/test_mock_storagepool.py +++ b/tests/test_mock_storagepool.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,16 +18,13 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA =20 +import cherrypy import json -import os import unittest from functools import partial =20 from tests.utils import patch_auth, request, run_server =20 -from wok.plugins.kimchi.mockmodel import MockModel - - model =3D None test_server =3D None =20 @@ -36,13 +33,12 @@ def setUpModule(): global test_server, model =20 patch_auth() - model =3D MockModel('/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') =20 =20 class MockStoragepoolTests(unittest.TestCase): diff --git a/tests/test_mock_storagevolume.py b/tests/test_mock_storagevolu= me.py index 3380bd5..4b3306b 100644 --- a/tests/test_mock_storagevolume.py +++ b/tests/test_mock_storagevolume.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,15 +18,13 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA =20 +import cherrypy import json -import os import unittest from functools import partial =20 from tests.utils import patch_auth, request, run_server =20 -from wok.plugins.kimchi.mockmodel import MockModel - from test_model_storagevolume import _do_volume_test =20 =20 @@ -38,13 +36,12 @@ def setUpModule(): global test_server, model =20 patch_auth() - model =3D MockModel('/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') =20 =20 class MockStorageVolumeTests(unittest.TestCase): diff --git a/tests/test_mockmodel.py b/tests/test_mockmodel.py index 826af12..19994ab 100644 --- a/tests/test_mockmodel.py +++ b/tests/test_mockmodel.py @@ -1,7 +1,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2013-2016 +# Copyright IBM Corp, 2013-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -27,7 +27,6 @@ from tests.utils import patch_auth, request, run_server from tests.utils import wait_task =20 from wok.exception import InvalidOperation -from wok.plugins.kimchi import mockmodel from wok.plugins.kimchi.osinfo import get_template_default =20 import iso_gen @@ -40,16 +39,15 @@ fake_iso =3D None def setUpModule(): global model, test_server, fake_iso cherrypy.request.headers =3D {'Accept': 'application/json'} - model =3D mockmodel.MockModel('/tmp/obj-store-test') patch_auth() - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model fake_iso =3D '/tmp/fake.iso' iso_gen.construct_fake_iso(fake_iso, True, '12.04', 'ubuntu') =20 =20 def tearDown(): test_server.stop() - os.unlink('/tmp/obj-store-test') os.unlink(fake_iso) =20 =20 diff --git a/tests/test_model_network.py b/tests/test_model_network.py index 79fda88..e83c515 100644 --- a/tests/test_model_network.py +++ b/tests/test_model_network.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,8 +18,11 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA =20 +import cherrypy import json +import mock import os +import tempfile import unittest from functools import partial =20 @@ -28,25 +31,26 @@ from tests.utils import run_server =20 from wok.rollbackcontext import RollbackContext =20 -from wok.plugins.kimchi.model.model import Model from wok.plugins.kimchi.model.featuretests import FeatureTests =20 - model =3D None +objectstore_loc =3D tempfile.mktemp() test_server =3D None =20 =20 -def setUpModule(): +@mock.patch('wok.plugins.kimchi.config.get_object_store') +def setUpModule(func): + func.return_value =3D objectstore_loc global test_server, model =20 patch_auth() - model =3D Model(None, '/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DFalse) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') + os.unlink(objectstore_loc) =20 =20 def _do_network_test(self, model, params): diff --git a/tests/test_model_storagepool.py b/tests/test_model_storagepool= .py index 2210a37..a1a5d95 100644 --- a/tests/test_model_storagepool.py +++ b/tests/test_model_storagepool.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,7 +18,9 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA =20 +import cherrypy import json +import mock import os import shutil import tempfile @@ -27,27 +29,27 @@ from functools import partial =20 from wok.rollbackcontext import RollbackContext =20 -from wok.plugins.kimchi.model.model import Model - from tests.utils import patch_auth, request from tests.utils import run_server =20 - model =3D None +objectstore_loc =3D tempfile.mktemp() test_server =3D None =20 =20 -def setUpModule(): +@mock.patch('wok.plugins.kimchi.config.get_object_store') +def setUpModule(func): + func.return_value =3D objectstore_loc global test_server, model =20 patch_auth() - model =3D Model(None, '/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DFalse) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') + os.unlink(objectstore_loc) =20 =20 class StoragepoolTests(unittest.TestCase): diff --git a/tests/test_model_storagevolume.py b/tests/test_model_storagevo= lume.py index cacfbb5..a1f1db9 100644 --- a/tests/test_model_storagevolume.py +++ b/tests/test_model_storagevolume.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,9 +18,12 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA =20 +import cherrypy import json +import mock import os import requests +import tempfile import unittest from functools import partial =20 @@ -32,24 +35,25 @@ from wok.config import paths from wok.rollbackcontext import RollbackContext =20 from wok.plugins.kimchi.config import READONLY_POOL_TYPE -from wok.plugins.kimchi.model.model import Model - =20 model =3D None +objectstore_loc =3D tempfile.mktemp() test_server =3D None =20 =20 -def setUpModule(): +@mock.patch('wok.plugins.kimchi.config.get_object_store') +def setUpModule(func): + func.return_value =3D objectstore_loc global test_server, model =20 patch_auth() - model =3D Model(None, '/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DFalse) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') + os.unlink(objectstore_loc) =20 =20 def _do_volume_test(self, model, pool_name): diff --git a/tests/test_rest.py b/tests/test_rest.py index a06cfe5..09fd8a5 100644 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -18,6 +18,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA =20 +import cherrypy import json import os import re @@ -32,7 +33,6 @@ from tests.utils import patch_auth, request, run_server, = wait_task from wok.asynctask import AsyncTask from wok.rollbackcontext import RollbackContext =20 -from wok.plugins.kimchi import mockmodel from wok.plugins.kimchi.osinfo import get_template_default =20 import iso_gen @@ -50,8 +50,8 @@ def setUpModule(): global test_server, model =20 patch_auth() - model =3D mockmodel.MockModel('/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 # Create fake ISO to do the tests iso_gen.construct_fake_iso(fake_iso, True, '12.04', 'ubuntu') @@ -61,7 +61,6 @@ def setUpModule(): =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') os.unlink(fake_iso) os.unlink("/var/lib/libvirt/images/fedora.iso") =20 diff --git a/tests/test_template.py b/tests/test_template.py index 8127a82..bf63acf 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,6 +18,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA =20 +import cherrypy import iso_gen import json import os @@ -28,7 +29,6 @@ from functools import partial from tests.utils import patch_auth, request, run_server =20 from wok.plugins.kimchi.config import READONLY_POOL_TYPE -from wok.plugins.kimchi.mockmodel import MockModel from wok.plugins.kimchi.model.featuretests import FeatureTests from wok.plugins.kimchi.model.templates import MAX_MEM_LIM =20 @@ -43,14 +43,13 @@ def setUpModule(): global test_server, model =20 patch_auth() - model =3D MockModel('/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model iso_gen.construct_fake_iso(MOCK_ISO, True, '14.04', 'ubuntu') =20 =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') =20 =20 class TemplateTests(unittest.TestCase): --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel