mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-10-24 22:27:41 -05:00
test_schema_plugin: Drop dependency on Tracker
Tracker is the best for testing plugins dealing with LDAP. The tests in test_schema_plugin are not used LDAP at all. Fixes: https://pagure.io/freeipa/issue/8954 Signed-off-by: Stanislav Levin <slev@altlinux.org> Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
1 parent
210739c0ed
commit
d4a3ed9dd4
1 file changed
+46
-25
@@ -9,21 +9,22 @@ Test the `ipaserver/plugins/schema.py` module.
|
||||
import pytest
|
||||
|
||||
from ipalib import api, errors
|
||||
from ipatests.test_xmlrpc.tracker.base import Tracker
|
||||
from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test
|
||||
|
||||
|
||||
@pytest.mark.tier1
|
||||
class TestParamFindAndShowCommand(XMLRPC_test):
|
||||
"""Test functionality of the ipa param-{find,show} command"""
|
||||
|
||||
tracker = Tracker()
|
||||
def run_command(self, command, *args, **options):
|
||||
cmd = api.Command[command]
|
||||
cmd_result = cmd(*args, **options)
|
||||
return cmd_result
|
||||
|
||||
def test_param_find(self):
|
||||
"""Test param-find command"""
|
||||
|
||||
cmd = "param_find"
|
||||
# right command without criteria
|
||||
result = self.tracker.run_command('param_find', u'user-add')
|
||||
result = self.run_command(cmd, "user-add")
|
||||
assert len(result['result']) != 0, result
|
||||
assert result['result'][0]['name'] == 'uid', result
|
||||
assert result['result'][0]['cli_name'] == 'login', result
|
||||
@@ -31,26 +32,30 @@ class TestParamFindAndShowCommand(XMLRPC_test):
|
||||
|
||||
# right command, right criteria
|
||||
criteria = u'postalcode'
|
||||
result = self.tracker.run_command('param_find', u'user-add', criteria)
|
||||
result = self.run_command(cmd, "user-add", criteria)
|
||||
assert len(result['result']) != 0, result
|
||||
for item in result['result']:
|
||||
assert (criteria in item['name'].lower() or
|
||||
criteria in item['doc'].lower()), item
|
||||
|
||||
# right command, wrong criteria
|
||||
result = self.tracker.run_command('param_find', u'user-add', u'fake')
|
||||
result = self.run_command(cmd, "user-add", "fake")
|
||||
assert len(result['result']) == 0, result
|
||||
|
||||
# wrong command, wrong criteria
|
||||
result = self.tracker.run_command('param_find', u'fake', u'fake')
|
||||
result = self.run_command(cmd, "fake", "fake")
|
||||
assert len(result['result']) == 0, result
|
||||
|
||||
# too many args
|
||||
with pytest.raises(errors.MaxArgumentError):
|
||||
self.run_command(cmd, "arg1", "arg2", "arg3")
|
||||
|
||||
def test_param_show(self):
|
||||
"""Test param-show command"""
|
||||
|
||||
# right command, right criteria
|
||||
criteria = u'uid'
|
||||
result = self.tracker.run_command('param_show', u'user-add', criteria)
|
||||
criteria = "uid"
|
||||
cmd = "param_show"
|
||||
result = self.run_command(cmd, "user-add", criteria)
|
||||
assert result['result'] is not None, result
|
||||
assert result['result']['name'] == 'uid', result
|
||||
assert result['result']['cli_name'] == 'login', result
|
||||
@@ -58,26 +63,33 @@ class TestParamFindAndShowCommand(XMLRPC_test):
|
||||
|
||||
# right command without criteria
|
||||
with pytest.raises(errors.RequirementError):
|
||||
self.tracker.run_command('param_show', u'user-add')
|
||||
self.run_command(cmd, "user-add")
|
||||
|
||||
# right command, wrong criteria
|
||||
with pytest.raises(errors.NotFound):
|
||||
self.tracker.run_command('param_show', u'user-add', u'fake')
|
||||
self.run_command(cmd, "user-add", "fake")
|
||||
|
||||
# wrong command, wrong criteria
|
||||
with pytest.raises(errors.NotFound):
|
||||
self.tracker.run_command('param_show', u'fake', u'fake')
|
||||
self.run_command(cmd, "fake", "fake")
|
||||
|
||||
# too many args
|
||||
with pytest.raises(errors.MaxArgumentError):
|
||||
self.run_command(cmd, "arg1", "arg2", "arg3")
|
||||
|
||||
|
||||
class TestOutputFindAndShowCommand(XMLRPC_test):
|
||||
"""Test functionality of the ipa output-{find,show} command"""
|
||||
tracker = Tracker()
|
||||
def run_command(self, command, *args, **options):
|
||||
cmd = api.Command[command]
|
||||
cmd_result = cmd(*args, **options)
|
||||
return cmd_result
|
||||
|
||||
def test_output_find(self):
|
||||
"""Test output-find command"""
|
||||
|
||||
cmd = "output_find"
|
||||
# right command without criteria
|
||||
result = self.tracker.run_command('output_find', u'user-add')
|
||||
result = self.run_command(cmd, "user-add")
|
||||
assert len(result['result']) != 0, result
|
||||
assert result['result'][0]['name'] == 'summary', result
|
||||
assert result['result'][0]['doc'] == \
|
||||
@@ -85,24 +97,29 @@ class TestOutputFindAndShowCommand(XMLRPC_test):
|
||||
|
||||
# right command, right criteria
|
||||
criteria = u'result'
|
||||
result = self.tracker.run_command('output_find', u'user-add', criteria)
|
||||
result = self.run_command(cmd, "user-add", criteria)
|
||||
assert len(result['result']) == 1, result
|
||||
assert criteria in result['result'][0]['name'].lower(), result
|
||||
|
||||
# right command, wrong criteria
|
||||
result = self.tracker.run_command('output_find', u'user-add', u'fake')
|
||||
result = self.run_command(cmd, "user-add", "fake")
|
||||
assert len(result['result']) == 0, result
|
||||
|
||||
# wrong command, wrong criteria
|
||||
result = self.tracker.run_command('output_find', u'fake', u'fake')
|
||||
result = self.run_command(cmd, "fake", "fake")
|
||||
assert len(result['result']) == 0, result
|
||||
|
||||
# too many args
|
||||
with pytest.raises(errors.MaxArgumentError):
|
||||
self.run_command(cmd, "arg1", "arg2", "arg3")
|
||||
|
||||
def test_output_show(self):
|
||||
"""Test output-show command"""
|
||||
|
||||
# right command, right criteria
|
||||
criteria = u'value'
|
||||
result = self.tracker.run_command('output_show', u'user-add', criteria)
|
||||
criteria = "value"
|
||||
cmd = "output_show"
|
||||
result = self.run_command(cmd, "user-add", criteria)
|
||||
assert len(result['result']) != 0, result
|
||||
assert criteria in result['result']['name'].lower(), result
|
||||
assert result['result']['doc'] == \
|
||||
@@ -110,15 +127,19 @@ class TestOutputFindAndShowCommand(XMLRPC_test):
|
||||
|
||||
# right command without criteria
|
||||
with pytest.raises(errors.RequirementError):
|
||||
self.tracker.run_command('output_show', u'user-add')
|
||||
self.run_command(cmd, "user-add")
|
||||
|
||||
# right command, wrong criteria
|
||||
with pytest.raises(errors.NotFound):
|
||||
self.tracker.run_command('output_show', u'user-add', u'fake')
|
||||
self.run_command(cmd, "user-add", "fake")
|
||||
|
||||
# wrong command, wrong criteria
|
||||
with pytest.raises(errors.NotFound):
|
||||
self.tracker.run_command('output_show', u'fake', u'fake')
|
||||
self.run_command(cmd, "fake", "fake")
|
||||
|
||||
# too many args
|
||||
with pytest.raises(errors.MaxArgumentError):
|
||||
self.run_command(cmd, "arg1", "arg2", "arg3")
|
||||
|
||||
|
||||
class TestSchemaCommand(XMLRPC_test):
|
||||
|
||||
Reference in new issue
Block a user