test_host_plugin: Use HostTracker fixtures

The racker object "remembers" expected state across several tests,
so only changes (rather than all expected state) need to be specified
in each test. Also, the tracker fixture will make it easy to use hosts
in other test modules.

This change makes the tests independent; any permutation of any subset
of these tests should now pass.

Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
Petr Viktorin authored and Tomas Babej committed 2015-01-14 11:40:28 +01:00
1 parent 8add23d401
commit 07545569ec
3 files changed
+813 -1232

No files matched your search

-40
View File
@@ -1,40 +0,0 @@
# Authors:
# Petr Viktorin <pviktori@redhat.com>
#
# Copyright (C) 2008 Red Hat
# see file 'COPYING' for use and warranty information
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Per-directory test configuration
"""
import pytest
from ipapython.version import API_VERSION
from ipalib import api
@pytest.fixture
def command(request):
try:
default_version = request.cls.default_version
except AttributeError:
default_version = API_VERSION
def cmd(cmd, *args, **options):
options.setdefault('version', default_version)
return api.Command[cmd](*args, **options)
return cmd
File diff suppressed because it is too large. Load diff
-29
View File
@@ -367,32 +367,3 @@ def raises_exact(expected_exception):
assert expected_exception.strerror == got_exception.strerror
else:
raise AssertionError('did not raise!')
class RPCTest(XMLRPC_test):
"""Base class for RPC tests"""
@classmethod
def setup_class(cls):
super(RPCTest, cls).setup_class()
cls.clean_up()
@classmethod
def teardown_class(cls):
cls.clean_up()
super(RPCTest, cls).teardown_class()
@classmethod
def clean_up(self):
"""Cleanup run on both setup and teardown
To be overridden in subclasses.
Usually calls the clean() method.
"""
@classmethod
def clean(cls, command, *args, **options):
"""Run a command, ignoring NotFound/EmptyModlist errors"""
try:
api.Command[command](*args, **options)
except (errors.NotFound, errors.EmptyModlist):
pass