From 414a40a667b404b8a4299100fa4a811204fb5a02 Mon Sep 17 00:00:00 2001 From: Brian Rosner Date: Wed, 22 May 2024 22:20:58 -0600 Subject: [PATCH] added cli tests --- tests/test_cli.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/test_cli.py diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 0000000..f130de0 --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,37 @@ +from unittest.mock import patch + +from click.testing import CliRunner + +import teufa.cli + + +@patch("teufa.server.Application") +def test_cli_server(MockApplication): + runner = CliRunner() + + result = runner.invoke(teufa.cli.server) + assert result.exit_code == 0 + + MockApplication.assert_called_once_with( + { + "bind": "127.0.0.1:8000", + "reload": False, + } + ) + MockApplication.return_value.run.assert_called_once_with() + + +@patch("teufa.server.Application") +def test_cli_server_dev(MockApplication): + runner = CliRunner() + + result = runner.invoke(teufa.cli.server, ["--dev"]) + assert result.exit_code == 0 + + MockApplication.assert_called_once_with( + { + "bind": "127.0.0.1:8000", + "reload": True, + } + ) + MockApplication.return_value.run.assert_called_once_with()