marvin_refactor: subfactory support for users

UserFactory will call on AccountFactory when it needs to be
instantiated.

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
Prasanna Santhanam 2013-04-18 07:54:57 +05:30
parent c1fd1eb0f6
commit 414bf4f625
4 changed files with 14 additions and 15 deletions

View File

@ -22,17 +22,16 @@ import hmac
import hashlib
import logging
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, mgmtDet, asyncTimeout=3600, logging=None,
@ -61,7 +60,7 @@ class cloudConnection(object):
% (self.protocol, self.mgtSvr, self.port, self.path)
def __copy__(self):
return cloudConnection(self.mgtSvr, self.port, self.user,
return CloudConnection(self.mgtSvr, self.port, self.user,
self.passwd, self.apiKey,
self.securityKey,
self.asyncTimeout, self.logging,

View File

@ -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()

View File

@ -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

View File

@ -176,7 +176,6 @@ def get_host_credentials(config, hostip):
raise Exception("Unresolvable host %s error is %s" % (hostip, e))
raise KeyError("Please provide the marvin configuration file with credentials to your hosts")
def get_process_status(hostip, port, username, password, linklocalip, process, hypervisor=None):
"""Double hop and returns a process status"""