test_integration: Adjust tests for pytest

- Customize install() instead of setup_class()
- Use pytest parametrization instead of test generators

Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
Petr Viktorin authored and Tomas Babej committed 2014-11-21 12:14:44 +01:00
1 parent 29c28786e3
commit d42c26c542
3 files changed
+30 -40

No files matched your search

+9 -16
View File
@@ -24,6 +24,7 @@ import base64
import glob
import contextlib
import nose
import pytest
from ipalib import x509
from ipapython import ipautil
@@ -31,7 +32,6 @@ from ipaplatform.paths import paths
from ipapython.dn import DN
from ipatests.test_integration.base import IntegrationTest
from ipatests.test_integration import tasks
from ipatests.pytest_plugins.ordering import ordered
_DEFAULT = object()
@@ -1143,7 +1143,6 @@ class TestClientInstall(CALessBase):
self.verify_installation()
@ordered
class TestIPACommands(CALessBase):
@classmethod
def install(cls):
@@ -1163,25 +1162,19 @@ class TestIPACommands(CALessBase):
cls.test_hostname = 'testhost.%s' % cls.master.domain.name
cls.test_service = 'test/%s' % cls.test_hostname
def check_ipa_command_not_available(self, command):
@pytest.mark.parametrize('cmd', (
'cert-status',
'cert-show',
'cert-find',
'cert-revoke',
'cert-remove-hold',
'cert-status'))
def test_cert_commands_unavailable(self, cmd):
"Verify that the given IPA subcommand is not available"
result = self.master.run_command(['ipa', command], raiseonerr=False)
assert_error(result, "ipa: ERROR: unknown command '%s'" % command)
def test_cert_commands_unavailable(self):
for cmd in (
'cert-status',
'cert-show',
'cert-find',
'cert-revoke',
'cert-remove-hold',
'cert-status'):
func = lambda: self.check_ipa_command_not_available(cmd)
func.description = 'Verify that %s command is not available' % cmd
func.test_argument = cmd
yield (func, )
def test_cert_help_unavailable(self):
"Verify that cert plugin help is not available"
result = self.master.run_command(['ipa', 'help', 'cert'],
@@ -55,26 +55,6 @@ class BaseTestLegacyClient(object):
# To allow custom validation dependent on the trust type
posix_trust = False
@classmethod
def setup_class(cls):
super(BaseTestLegacyClient, cls).setup_class()
cls.ad = cls.ad_domains[0].ads[0]
cls.legacy_client = cls.host_by_role(cls.required_extra_roles[0])
# Determine whether the subdomain AD is available
try:
child_ad = cls.host_by_role(cls.optional_extra_roles[0])
cls.ad_subdomain = '.'.join(
child_ad.hostname.split('.')[1:])
except LookupError:
cls.ad_subdomain = None
tasks.apply_common_fixes(cls.legacy_client)
for f in cls.backup_files:
tasks.backup_file(cls.legacy_client, f)
def test_apply_advice(self):
# Obtain the advice from the server
tasks.kinit_admin(self.master)
@@ -359,6 +339,23 @@ class BaseTestLegacyClient(object):
cls.master.run_command(['ipa', 'user-disable', 'disabledipauser'])
cls.ad = cls.ad_domains[0].ads[0]
cls.legacy_client = cls.host_by_role(cls.required_extra_roles[0])
# Determine whether the subdomain AD is available
try:
child_ad = cls.host_by_role(cls.optional_extra_roles[0])
cls.ad_subdomain = '.'.join(
child_ad.hostname.split('.')[1:])
except LookupError:
cls.ad_subdomain = None
tasks.apply_common_fixes(cls.legacy_client)
for f in cls.backup_files:
tasks.backup_file(cls.legacy_client, f)
@classmethod
def uninstall(cls):
cls.master.run_command(['ipa', 'user-del', 'disabledipauser'],
+4 -4
View File
@@ -30,8 +30,8 @@ class TestSudo(IntegrationTest):
topology = 'line'
@classmethod
def setup_class(cls):
super(TestSudo, cls).setup_class()
def install(cls):
super(TestSudo, cls).install()
cls.client = cls.clients[0]
@@ -70,10 +70,10 @@ class TestSudo(IntegrationTest):
'localuser'])
@classmethod
def teardown_class(cls):
def uninstall(cls):
cls.client.run_command(['groupdel', 'localgroup'], raiseonerr=False)
cls.client.run_command(['userdel', 'localuser'], raiseonerr=False)
super(TestSudo, cls).teardown_class()
super(TestSudo, cls).uninstall()
def list_sudo_commands(self, user, raiseonerr=False, verbose=False):
clear_sssd_cache(self.client)