diff --git a/.coverage b/.coverage index ade5727..fde3bfd 100644 Binary files a/.coverage and b/.coverage differ diff --git a/Makefile b/Makefile index 9beb8a4..2b74d48 100644 --- a/Makefile +++ b/Makefile @@ -34,3 +34,6 @@ update: docker: docker build --no-cache -f Dockerfile -t change_me-smoke . docker run --rm change_me-smoke + +app: + poetry run python -m change_me diff --git a/README.md b/README.md index 8eb8aee..55ae526 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ To install the library run: `pip install change-me` 5. `poetry publish --build` to build and publish to https://pypi.org/project/change-me -## Usage +## Module Usage ``` """Basic docstring for my module.""" @@ -26,3 +26,8 @@ logger.info("Hello World!") if __name__ == "__main__": main() ``` + +## Program Usage +```bash +poetry run python -m change_me +``` diff --git a/src/change_me/__main__.py b/src/change_me/__main__.py index 1304e39..2161425 100644 --- a/src/change_me/__main__.py +++ b/src/change_me/__main__.py @@ -8,19 +8,19 @@ from change_me.utils import setup_logger -def main(log_level: str) -> None: +def main(log_level: str = DEFAULT_LOG_LEVEL) -> None: """Run the pipeline.""" setup_logger(filename="log_file", log_dir=None, log_level=log_level) - logger.info("Hello world!") + logger.info("Hello, world!") -if __name__ == "__main__": - parser = argparse.ArgumentParser() +if __name__ == "__main__": # pragma: no cover + parser = argparse.ArgumentParser("Run the pipeline.") parser.add_argument( "--log-level", default=DEFAULT_LOG_LEVEL, - choices=list(LogLevel), - help="Log level.", + choices=list(LogLevel()), + help="Set the log level.", ) args = parser.parse_args() diff --git a/tests/main_test.py b/tests/main_test.py new file mode 100644 index 0000000..add1078 --- /dev/null +++ b/tests/main_test.py @@ -0,0 +1,10 @@ +"""Test the main program.""" + +from change_me.__main__ import main + + +def test_main(): + """Test the main function.""" + result = main() + + assert result is None diff --git a/tests/utils_test.py b/tests/utils_test.py index e5ddf72..8da207f 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -3,13 +3,23 @@ from pathlib import Path from tempfile import TemporaryDirectory +from change_me.definitions import LogLevel from change_me.utils import setup_logger -def test_logger_init(): +def test_logger_init() -> None: """Test logger initialization.""" with TemporaryDirectory() as log_dir: log_dir_path = Path(log_dir) log_filepath = setup_logger(filename="log_file", log_dir=log_dir_path) assert Path(log_filepath).exists() assert not Path(log_filepath).exists() + + +def test_log_level() -> None: + """Test the log level.""" + # Act + log_levels = list(LogLevel()) + + # Assert + assert type(log_levels) is list