mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 07:33:27 -06:00
57: to_cli() function no longer replaces '__' with '.'; from_cli() function no longer replaces '.' with '__'; updated unit tests
This commit is contained in:
parent
8865f516df
commit
e618d99bc7
@ -32,7 +32,7 @@ def to_cli(name):
|
||||
Command Line Interface.
|
||||
"""
|
||||
assert isinstance(name, str)
|
||||
return name.replace('__', '.').replace('_', '-')
|
||||
return name.replace('_', '-')
|
||||
|
||||
|
||||
def from_cli(cli_name):
|
||||
@ -41,7 +41,7 @@ def from_cli(cli_name):
|
||||
Python identifier.
|
||||
"""
|
||||
assert isinstance(cli_name, basestring)
|
||||
return cli_name.replace('-', '_').replace('.', '__')
|
||||
return cli_name.replace('-', '_')
|
||||
|
||||
|
||||
def check_identifier(name):
|
||||
@ -143,7 +143,7 @@ class Proxy(ReadOnly):
|
||||
"""
|
||||
if proxy_name is None:
|
||||
proxy_name = obj.__class__.__name__
|
||||
assert isinstance(proxy_name, str)
|
||||
check_identifier(proxy_name)
|
||||
object.__setattr__(self, '_Proxy__obj', obj)
|
||||
object.__setattr__(self, 'name', proxy_name)
|
||||
if callable(obj):
|
||||
|
@ -28,17 +28,13 @@ from ipalib import plugable, errors
|
||||
def test_to_cli():
|
||||
f = plugable.to_cli
|
||||
assert f('initialize') == 'initialize'
|
||||
assert f('find_everything') == 'find-everything'
|
||||
assert f('user__add') == 'user.add'
|
||||
assert f('meta_service__do_something') == 'meta-service.do-something'
|
||||
assert f('user_add') == 'user-add'
|
||||
|
||||
|
||||
def test_from_cli():
|
||||
f = plugable.from_cli
|
||||
assert f('initialize') == 'initialize'
|
||||
assert f('find-everything') == 'find_everything'
|
||||
assert f('user.add') == 'user__add'
|
||||
assert f('meta-service.do-something') == 'meta_service__do_something'
|
||||
assert f('user-add') == 'user_add'
|
||||
|
||||
|
||||
def test_valid_identifier():
|
||||
@ -139,10 +135,10 @@ def test_Proxy():
|
||||
|
||||
# Test that proxy_name can be overriden:
|
||||
i = do_something()
|
||||
p = CommandProxy(i, proxy_name='user__add')
|
||||
p = CommandProxy(i, proxy_name='user_add')
|
||||
assert '__dict__' not in dir(p)
|
||||
assert p.name == 'user__add'
|
||||
assert str(p) == 'user.add'
|
||||
assert p.name == 'user_add'
|
||||
assert str(p) == 'user-add'
|
||||
assert repr(p) == 'CommandProxy(<my repr>)'
|
||||
assert p(1) == 2
|
||||
assert p.validate(1) == 3
|
||||
|
Loading…
Reference in New Issue
Block a user