From 00620001ee82532759ac200ffc615b33a9d478bd Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Sun, 19 Mar 2023 22:40:20 +0100 Subject: [PATCH] test: command line interface (#63) Closes #1. ### Summary of Changes Test the command line interface with `pytest`. --------- Co-authored-by: lars-reimann --- tests/library_analyzer/__init__.py | 0 tests/library_analyzer/cli/__init__.py | 0 tests/library_analyzer/cli/test_cli.py | 95 ++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 tests/library_analyzer/__init__.py create mode 100644 tests/library_analyzer/cli/__init__.py create mode 100644 tests/library_analyzer/cli/test_cli.py diff --git a/tests/library_analyzer/__init__.py b/tests/library_analyzer/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/library_analyzer/cli/__init__.py b/tests/library_analyzer/cli/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/library_analyzer/cli/test_cli.py b/tests/library_analyzer/cli/test_cli.py new file mode 100644 index 00000000..adbdbc9b --- /dev/null +++ b/tests/library_analyzer/cli/test_cli.py @@ -0,0 +1,95 @@ +import subprocess + + +def test_cli_api() -> None: + subprocess.run( + [ + "poetry", + "run", + "analyze-library", + "api", + "-p", + "library_analyzer", + "-s", + "src", + "-o", + "out", + ], + check=True, + ) + + +def test_cli_usages() -> None: + subprocess.run( + [ + "poetry", + "run", + "analyze-library", + "usages", + "-p", + "library_analyzer", + "-c", + "library_analyzer", + "-o", + "out", + ], + check=True, + ) + + +def test_cli_annotations() -> None: + subprocess.run( + [ + "poetry", + "run", + "analyze-library", + "annotations", + "-a", + "tests/data/removeAnnotations/api_data.json", + "-u", + "tests/data/removeAnnotations/usage_data.json", + "-o", + "out/annotations.json", + ], + check=True, + ) + + +def test_cli_all() -> None: + subprocess.run( + [ + "poetry", + "run", + "analyze-library", + "all", + "-p", + "library_analyzer", + "-s", + "src", + "-c", + "library_analyzer", + "-o", + "out", + ], + check=True, + ) + + +def test_cli_migration() -> None: + subprocess.run( + [ + "poetry", + "run", + "analyze-library", + "migrate", + "-a1", + "tests/data/migration/apiv1_data.json", + "-a2", + "tests/data/migration/apiv2_data.json", + "-a", + "tests/data/migration/annotationv1.json", + "-o", + "out", + ], + check=True, + )