subfactory support for users UserFactory will call on AccountFactory when it needs to be instantiated.
Signed-off-by: Prasanna Santhanam <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/94b18c6e Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/94b18c6e Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/94b18c6e Branch: refs/heads/marvin_refactor Commit: 94b18c6e932270092eed7ec254d25a5b77c47b49 Parents: e82ba58 Author: Prasanna Santhanam <[email protected]> Authored: Thu Apr 18 07:54:57 2013 +0530 Committer: Prasanna Santhanam <[email protected]> Committed: Thu Apr 18 07:54:57 2013 +0530 ---------------------------------------------------------------------- tools/marvin/marvin/cloudstackConnection.py | 12 ++++++------ tools/marvin/marvin/cloudstackTestClient.py | 4 ++-- .../marvin/integration/lib/factory/UserFactory.py | 6 +++--- .../integration/lib/factory/test/testFactories.py | 11 ++++++----- tools/marvin/marvin/integration/lib/utils.py | 2 +- 5 files changed, 18 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/94b18c6e/tools/marvin/marvin/cloudstackConnection.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/cloudstackConnection.py b/tools/marvin/marvin/cloudstackConnection.py index 14b12e7..b1d5a51 100644 --- a/tools/marvin/marvin/cloudstackConnection.py +++ b/tools/marvin/marvin/cloudstackConnection.py @@ -21,16 +21,16 @@ import base64 import hmac import hashlib import time -import cloudstackException -from cloudstackAPI import * -import jsonHelper +import marvin.cloudstackException +from marvin.cloudstackAPI import * +import marvin.jsonHelper from requests import ConnectionError from requests import HTTPError from requests import Timeout from requests import RequestException -class cloudConnection(object): +class CloudConnection(object): """ Connections to make API calls to the cloudstack management server """ def __init__(self, mgtSvr, port=8096, apiKey=None, securityKey=None, @@ -49,13 +49,13 @@ class cloudConnection(object): (self.apiKey is None and self.securityKey is None): self.auth = False if scheme not in ['http', 'https']: - raise RequestException("Protocol must be HTTP") + raise RequestException("Protocol must be HTTP") self.protocol = scheme self.baseurl = "%s://%s:%d/%s"\ % (self.protocol, self.mgtSvr, self.port, self.path) def __copy__(self): - return cloudConnection(self.mgtSvr, self.port, self.apiKey, + return CloudConnection(self.mgtSvr, self.port, self.apiKey, self.securityKey, self.asyncTimeout, self.logging, self.protocol, self.path) http://git-wip-us.apache.org/repos/asf/cloudstack/blob/94b18c6e/tools/marvin/marvin/cloudstackTestClient.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/cloudstackTestClient.py b/tools/marvin/marvin/cloudstackTestClient.py index 85552ed..5e0a82f 100644 --- a/tools/marvin/marvin/cloudstackTestClient.py +++ b/tools/marvin/marvin/cloudstackTestClient.py @@ -26,7 +26,7 @@ import hashlib class cloudstackTestClient(object): def __init__(self, mgtSvr=None, port=8096, apiKey = None, securityKey = None, asyncTimeout=3600, defaultWorkerThreads=10, logging=None): - self.connection = cloudstackConnection.cloudConnection(mgtSvr, port, apiKey, securityKey, asyncTimeout, logging) + self.connection = cloudstackConnection.CloudConnection(mgtSvr, port, apiKey, securityKey, asyncTimeout, logging) self.apiClient = cloudstackAPIClient.CloudStackAPIClient(self.connection) self.dbConnection = None self.asyncJobMgr = None @@ -111,7 +111,7 @@ class cloudstackTestClient(object): apiKey = registerUserRes.apikey securityKey = registerUserRes.secretkey - newUserConnection = cloudstackConnection.cloudConnection(self.connection.mgtSvr, self.connection.port, + newUserConnection = cloudstackConnection.CloudConnection(self.connection.mgtSvr, self.connection.port, apiKey, securityKey, self.connection.asyncTimeout, self.connection.logging) self.userApiClient = cloudstackAPIClient.CloudStackAPIClient(newUserConnection) self.userApiClient.connection = newUserConnection http://git-wip-us.apache.org/repos/asf/cloudstack/blob/94b18c6e/tools/marvin/marvin/integration/lib/factory/UserFactory.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/integration/lib/factory/UserFactory.py b/tools/marvin/marvin/integration/lib/factory/UserFactory.py index 9f0cc77..1b13b8b 100644 --- a/tools/marvin/marvin/integration/lib/factory/UserFactory.py +++ b/tools/marvin/marvin/integration/lib/factory/UserFactory.py @@ -16,14 +16,14 @@ # under the License. import factory from marvin.integration.lib.base import User -from marvin.integration.lib.factory import CloudStackBaseFactory +from marvin.integration.lib.factory.CloudStackBaseFactory import CloudStackBaseFactory from marvin.integration.lib.factory.AccountFactory import AccountFactory class UserFactory(CloudStackBaseFactory): FACTORY_FOR = User.User - account = factory.SubFactory(AccountFactory) + account = factory.SubFactory(AccountFactory).factory() email = account.email firstname = account.firstname lastname = account.lastname @@ -31,4 +31,4 @@ class UserFactory(CloudStackBaseFactory): username = account.username class AdminUserFactory(UserFactory): - account = factory.SubFactory(AccountFactory, accounttype=1) + account = factory.SubFactory(AccountFactory, accounttype=1).factory() http://git-wip-us.apache.org/repos/asf/cloudstack/blob/94b18c6e/tools/marvin/marvin/integration/lib/factory/test/testFactories.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/integration/lib/factory/test/testFactories.py b/tools/marvin/marvin/integration/lib/factory/test/testFactories.py index c7a0a2c..cb7165f 100644 --- a/tools/marvin/marvin/integration/lib/factory/test/testFactories.py +++ b/tools/marvin/marvin/integration/lib/factory/test/testFactories.py @@ -16,6 +16,7 @@ # under the License. import unittest +import logging from marvin.cloudstackTestClient import cloudstackTestClient from marvin.integration.lib.common import get_template @@ -40,7 +41,7 @@ from marvin.integration.lib.base.User import User class AccountFactoryTest(unittest.TestCase): def setUp(self): - self.apiClient = cloudstackTestClient(mgtSvr='localhost').getApiClient() + self.apiClient = cloudstackTestClient(mgtSvr='localhost', logging=logging.getLogger('factories.cloudstack')).getApiClient() def test_userAccountFactory(self): af = AccountFactory() @@ -74,7 +75,7 @@ class AccountFactoryTest(unittest.TestCase): class ServiceOfferingFactoryTest(unittest.TestCase): def setUp(self): - self.apiClient = cloudstackTestClient(mgtSvr='localhost').getApiClient() + self.apiClient = cloudstackTestClient(mgtSvr='localhost', logging=logging.getLogger('factories.cloudstack')).getApiClient() def test_serviceOfferingFactory(self): sf = ServiceOfferingFactory() @@ -89,7 +90,7 @@ class ServiceOfferingFactoryTest(unittest.TestCase): class NetworkOfferingFactoryTest(unittest.TestCase): def setUp(self): - self.apiClient = cloudstackTestClient(mgtSvr='localhost').getApiClient() + self.apiClient = cloudstackTestClient(mgtSvr='localhost', logging=logging.getLogger('factories.cloudstack')).getApiClient() def test_defaultSourceNatOfferingFactory(self): snatOfferingFactory = DefaultIsolatedNetworkOfferingWithSourceNatServiceFactory() @@ -107,7 +108,7 @@ class NetworkOfferingFactoryTest(unittest.TestCase): class VirtualMachineFactoryTest(unittest.TestCase): def setUp(self): - self.apiClient = cloudstackTestClient(mgtSvr='localhost').getApiClient() + self.apiClient = cloudstackTestClient(mgtSvr='localhost', logging=logging.getLogger('factories.cloudstack')).getApiClient() def tearDown(self): pass @@ -123,7 +124,7 @@ class VirtualMachineFactoryTest(unittest.TestCase): class UserFactorySubFactoryTest(unittest.TestCase): def setUp(self): - self.apiClient = cloudstackTestClient(mgtSvr='localhost').getApiClient() + self.apiClient = cloudstackTestClient(mgtSvr='localhost', logging=logging.getLogger('factories.cloudstack')).getApiClient() def tearDown(self): pass http://git-wip-us.apache.org/repos/asf/cloudstack/blob/94b18c6e/tools/marvin/marvin/integration/lib/utils.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/integration/lib/utils.py b/tools/marvin/marvin/integration/lib/utils.py index cff24a1..74d4d27 100644 --- a/tools/marvin/marvin/integration/lib/utils.py +++ b/tools/marvin/marvin/integration/lib/utils.py @@ -138,7 +138,7 @@ def fetch_api_client(config_file='datacenterCfg'): testClientLogger = logging.getLogger("testClient") asyncTimeout = 3600 return cloudstackAPIClient.CloudStackAPIClient( - marvin.cloudstackConnection.cloudConnection( + marvin.cloudstackConnection.CloudConnection( mgt.mgtSvrIp, mgt.port, mgt.apiKey,
