mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
test request with callback
This commit is contained in:
parent
88cdeb0b96
commit
c603a4e41b
3 changed files with 30 additions and 1 deletions
|
@ -26,7 +26,14 @@ _global:
|
||||||
help: Display Yoloswag versions
|
help: Display Yoloswag versions
|
||||||
action: callback
|
action: callback
|
||||||
callback:
|
callback:
|
||||||
method: yoloswag_version
|
method: test.src.testauth.yoloswag_version
|
||||||
|
return: true
|
||||||
|
-w:
|
||||||
|
full: --wersion
|
||||||
|
help: Not existing function
|
||||||
|
action: callback
|
||||||
|
callback:
|
||||||
|
method: test.src.testauth.not_existing_function
|
||||||
return: true
|
return: true
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
|
|
|
@ -36,3 +36,7 @@ def testauth_only_cli():
|
||||||
|
|
||||||
def testauth_ldap():
|
def testauth_ldap():
|
||||||
return "some_data_from_ldap"
|
return "some_data_from_ldap"
|
||||||
|
|
||||||
|
|
||||||
|
def yoloswag_version(*args, **kwargs):
|
||||||
|
return "666"
|
||||||
|
|
|
@ -244,3 +244,21 @@ class TestAuthCLI:
|
||||||
translation = m18n.g("invalid_password")
|
translation = m18n.g("invalid_password")
|
||||||
expected_msg = translation.format()
|
expected_msg = translation.format()
|
||||||
assert expected_msg in str(exception)
|
assert expected_msg in str(exception)
|
||||||
|
|
||||||
|
def test_request_with_callback(self, moulinette_cli, capsys, mocker):
|
||||||
|
mocker.patch("getpass.getpass", return_value="default")
|
||||||
|
moulinette_cli.run(["--version"], output_as="plain")
|
||||||
|
message = capsys.readouterr()
|
||||||
|
|
||||||
|
assert "666" in message.out
|
||||||
|
|
||||||
|
moulinette_cli.run(["-v"], output_as="plain")
|
||||||
|
message = capsys.readouterr()
|
||||||
|
|
||||||
|
assert "666" in message.out
|
||||||
|
|
||||||
|
with pytest.raises(MoulinetteError):
|
||||||
|
moulinette_cli.run(["--wersion"], output_as="plain")
|
||||||
|
message = capsys.readouterr()
|
||||||
|
|
||||||
|
assert "cannot get value from callback method" in message.err
|
||||||
|
|
Loading…
Add table
Reference in a new issue