From 7a89c5966c565269f190f5a55e682151a5bee11c Mon Sep 17 00:00:00 2001 From: Graham Tibbitts Date: Mon, 27 Nov 2023 08:00:19 -0700 Subject: [PATCH] Fix CLI test to work in GitHub workflow --- prosper_bot/cli/__init__.py | 2 +- tests/test_cli.py | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/prosper_bot/cli/__init__.py b/prosper_bot/cli/__init__.py index 2482a25..f114196 100644 --- a/prosper_bot/cli/__init__.py +++ b/prosper_bot/cli/__init__.py @@ -20,7 +20,7 @@ def _schema(): } -def build_config(): +def build_config() -> Config: """Compiles all the config sources into a single config.""" return Config.autoconfig( ["prosper-api", "prosper-bot"], _arg_parser(), validate=True diff --git a/tests/test_cli.py b/tests/test_cli.py index bd144e0..9057e40 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,10 +1,31 @@ import sys +from decimal import Decimal from prosper_bot.cli import build_config class TestCli: def test_build_config(self, mocker): - mocker.patch.object(sys, "argv", []) + mocker.patch.object( + sys, + "argv", + [ + "test-cli", + "--client-id=0123456789abcdef0123456789abcdef", + "--username=fake-username", + "--token-cache=fake-token-cache", + ], + ) - build_config() + config = build_config() + + assert config._config_dict["bot"] == { + "dry-run": False, + "min-bid": Decimal("25"), + "verbose": False, + } + assert config._config_dict["credentials"] == { + "client-id": "f3c747293f3e4dc5a27a6ff3cf4f6805", + "username": "fake-username", + } + assert config._config_dict["auth"]["token-cache"] is not None