|
| 1 | +# Copyright (C) 2024 twyleg |
| 2 | +# fmt: off |
| 3 | +import argparse |
| 4 | +from pathlib import Path |
| 5 | + |
| 6 | +from simple_python_app.generic_application import GenericApplication |
| 7 | + |
| 8 | +from fixtures import print_tmp_path, valid_custom_logging_config, project_dir |
| 9 | + |
| 10 | +# |
| 11 | +# General naming convention for unit tests: |
| 12 | +# test_INITIALSTATE_ACTION_EXPECTATION |
| 13 | +# |
| 14 | + |
| 15 | + |
| 16 | +FILE_DIR = Path(__file__).parent |
| 17 | + |
| 18 | + |
| 19 | +class BaseTestApplication(GenericApplication): |
| 20 | + def __init__(self, **kwargs): |
| 21 | + super().__init__( |
| 22 | + application_name="test_application", |
| 23 | + version="0.0.1", |
| 24 | + logging_init_default_logging_enabled=False, # Caution: This is necessary because otherwise log init will |
| 25 | + logging_init_custom_logging_enabled=False, # remove pytest handler and caplog won't work. |
| 26 | + application_config_init_enabled=False, |
| 27 | + **kwargs |
| 28 | + ) |
| 29 | + |
| 30 | + def run(self, argparser: argparse.ArgumentParser) -> None: |
| 31 | + pass |
| 32 | + |
| 33 | + |
| 34 | +class TestCli: |
| 35 | + def test_NoArgument_Started_SuccessfullReturnCode(self, caplog, project_dir): |
| 36 | + test_app = BaseTestApplication() |
| 37 | + assert test_app.start([]) == 0 |
| 38 | + |
| 39 | + def test_PrintVersion_Started_VersionPrintedSuccessfullReturnCode(self, caplog, project_dir): |
| 40 | + test_app = BaseTestApplication() |
| 41 | + assert test_app.start(["--version"]) == 0 |
0 commit comments