mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Add test without action
This commit is contained in:
parent
1a95e6e779
commit
53cbca2c1e
2 changed files with 26 additions and 16 deletions
|
@ -6,6 +6,20 @@ import getpass
|
||||||
import locale
|
import locale
|
||||||
import logging
|
import logging
|
||||||
from argparse import SUPPRESS
|
from argparse import SUPPRESS
|
||||||
|
from collections import OrderedDict
|
||||||
|
from datetime import date, datetime
|
||||||
|
|
||||||
|
import argcomplete
|
||||||
|
|
||||||
|
from moulinette import msignals, m18n
|
||||||
|
from moulinette.actionsmap import ActionsMap
|
||||||
|
from moulinette.core import MoulinetteError
|
||||||
|
from moulinette.interfaces import (
|
||||||
|
BaseActionsMapParser,
|
||||||
|
BaseInterface,
|
||||||
|
ExtendedArgumentParser,
|
||||||
|
)
|
||||||
|
from moulinette.utils import log
|
||||||
|
|
||||||
# Monkeypatch _get_action_name function because there is an annoying bug
|
# Monkeypatch _get_action_name function because there is an annoying bug
|
||||||
# Explained here: https://bugs.python.org/issue29298
|
# Explained here: https://bugs.python.org/issue29298
|
||||||
|
@ -39,22 +53,6 @@ def monkey_get_action_name(argument):
|
||||||
|
|
||||||
argparse._get_action_name = monkey_get_action_name
|
argparse._get_action_name = monkey_get_action_name
|
||||||
|
|
||||||
from collections import OrderedDict
|
|
||||||
from datetime import date, datetime
|
|
||||||
|
|
||||||
import argcomplete
|
|
||||||
|
|
||||||
from moulinette import msignals, m18n
|
|
||||||
from moulinette.actionsmap import ActionsMap
|
|
||||||
from moulinette.core import MoulinetteError
|
|
||||||
from moulinette.interfaces import (
|
|
||||||
BaseActionsMapParser,
|
|
||||||
BaseInterface,
|
|
||||||
ExtendedArgumentParser,
|
|
||||||
)
|
|
||||||
from moulinette.utils import log
|
|
||||||
|
|
||||||
|
|
||||||
logger = log.getLogger("moulinette.cli")
|
logger = log.getLogger("moulinette.cli")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,10 @@ class TestAuthAPI:
|
||||||
mocker.patch("moulinette.Moulinette18n.g", return_value=error)
|
mocker.patch("moulinette.Moulinette18n.g", return_value=error)
|
||||||
moulinette_webapi.get("/test-auth/with_type_int/yoloswag", status=400)
|
moulinette_webapi.get("/test-auth/with_type_int/yoloswag", status=400)
|
||||||
|
|
||||||
|
def test_request_arg_without_action(self, moulinette_webapi, caplog, mocker):
|
||||||
|
self.login(moulinette_webapi)
|
||||||
|
moulinette_webapi.get("/test-auth", status=404)
|
||||||
|
|
||||||
|
|
||||||
class TestAuthCLI:
|
class TestAuthCLI:
|
||||||
def test_login(self, moulinette_cli, capsys, mocker):
|
def test_login(self, moulinette_cli, capsys, mocker):
|
||||||
|
@ -336,3 +340,11 @@ class TestAuthCLI:
|
||||||
|
|
||||||
message = capsys.readouterr()
|
message = capsys.readouterr()
|
||||||
assert "invalid int value" in message.err
|
assert "invalid int value" in message.err
|
||||||
|
|
||||||
|
def test_request_arg_without_action(self, moulinette_cli, capsys, mocker):
|
||||||
|
with pytest.raises(SystemExit):
|
||||||
|
moulinette_cli.run(["testauth"], output_as="plain")
|
||||||
|
|
||||||
|
message = capsys.readouterr()
|
||||||
|
|
||||||
|
assert "error: the following arguments are required:" in message.err
|
||||||
|
|
Loading…
Reference in a new issue