Add test without action

This commit is contained in:
Kay0u 2021-01-26 21:19:26 +01:00
parent 1a95e6e779
commit 53cbca2c1e
No known key found for this signature in database
GPG key ID: AAFEEB16CFA2AE2D
2 changed files with 26 additions and 16 deletions

View file

@ -6,6 +6,20 @@ import getpass
import locale
import logging
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
# 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
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")

View file

@ -207,6 +207,10 @@ class TestAuthAPI:
mocker.patch("moulinette.Moulinette18n.g", return_value=error)
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:
def test_login(self, moulinette_cli, capsys, mocker):
@ -336,3 +340,11 @@ class TestAuthCLI:
message = capsys.readouterr()
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