test_webui: Don't use __init__ for test classes

https://fedorahosted.org/freeipa/ticket/4610

Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
Petr Viktorin 2014-10-10 16:04:05 +02:00 committed by Tomas Babej
parent b64f91fb43
commit 82e41dc7a4
8 changed files with 24 additions and 28 deletions

View File

@ -93,6 +93,7 @@ class test_automember(UI_driver):
self.init_app()
host_util = host_tasks()
host_util.setup(self.driver, self.config)
domain = self.config.get('ipa_domain')
host1 = 'web1.%s' % domain
host2 = 'web2.%s' % domain

View File

@ -29,8 +29,8 @@ ENTITY = 'cert'
class test_cert(UI_driver):
def __init__(self, *args, **kwargs):
super(test_cert, self).__init__(args, kwargs)
def setup(self, *args, **kwargs):
super(test_cert, self).setup(*args, **kwargs)
if not self.has_ca():
self.skip('CA not configured')

View File

@ -87,8 +87,8 @@ CONFIG_MOD_DATA = {
class test_dns(UI_driver):
def __init__(self, *args, **kwargs):
super(test_dns, self).__init__(args, kwargs)
def setup(self, *args, **kwargs):
super(test_dns, self).setup(*args, **kwargs)
if not self.has_dns():
self.skip('DNS not configured')

View File

@ -34,8 +34,8 @@ ENTITY = 'host'
class host_tasks(UI_driver):
def __init__(self, *args, **kwargs):
super(host_tasks, self).__init__(args, kwargs)
def setup(self, *args, **kwargs):
super(host_tasks, self).setup(*args, **kwargs)
self.prep_data()
self.prep_data2()

View File

@ -48,7 +48,8 @@ class test_hostgroup(UI_driver):
Hostgroup associations
"""
self.init_app()
host = host_tasks(self.driver, self.config)
host = host_tasks()
host.setup(self.driver, self.config)
# prepare
# -------
@ -89,7 +90,8 @@ class test_hostgroup(UI_driver):
Hostgroup indirect associations
"""
self.init_app()
host = host_tasks(self.driver, self.config)
host = host_tasks()
host.setup(self.driver, self.config)
# add
# ---

View File

@ -46,7 +46,8 @@ class test_netgroup(UI_driver):
Mod: netgroup
"""
self.init_app()
host = host_tasks(self.driver, self.config)
host = host_tasks()
host.setup(self.driver, self.config)
self.add_record(netgroup.ENTITY, netgroup.DATA2)
self.add_record(user.ENTITY, user.DATA)

View File

@ -95,9 +95,8 @@ class trust_tasks(UI_driver):
class test_trust(trust_tasks):
def __init__(self, *args, **kwargs):
super(test_trust, self).__init__(args, kwargs)
def setup(self, *args, **kwargs):
super(test_trust, self).setup(*args, **kwargs)
if not self.has_trusts():
self.skip('Trusts not configured')
@ -121,7 +120,8 @@ class test_trust(trust_tasks):
self.init_app()
r_tasks = range_tasks(self.driver, self.config)
r_tasks = range_tasks()
r_tasks.setup(self.driver, self.config)
r_tasks.get_shifts()
range_add = r_tasks.get_add_data('')
base_id = range_add[2][2]

View File

@ -117,12 +117,18 @@ class UI_driver(object):
if NO_SELENIUM:
raise nose.SkipTest('Selenium not installed')
def __init__(self, driver=None, config=None):
def setup(self, driver=None, config=None):
self.request_timeout = 30
self.driver = driver
self.config = config
if not config:
self.load_config()
if not self.driver:
self.driver = self.get_driver()
self.get_driver().maximize_window()
def teardown(self):
self.driver.quit()
def load_config(self):
"""
@ -161,20 +167,6 @@ class UI_driver(object):
if 'type' not in c:
c['type'] = DEFAULT_TYPE
def setup(self):
"""
Test setup
"""
if not self.driver:
self.driver = self.get_driver()
self.driver.maximize_window()
def teardown(self):
"""
Test clean up
"""
self.driver.quit()
def get_driver(self):
"""
Get WebDriver according to configuration