From dcbcf8eb3a9e0bff872fd5df42861910f258d1a4 Mon Sep 17 00:00:00 2001 From: Malcolm Greaves Date: Fri, 1 Nov 2024 17:44:08 -0400 Subject: [PATCH] restore CLI tests --- .../new_project/exe/bionemo_subpackage.py | 3 +- .../test_new_project/test_cli_tools.py | 64 +++++++++++++++++-- 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/internal/infra-bionemo/src/infra_bionemo/new_project/exe/bionemo_subpackage.py b/internal/infra-bionemo/src/infra_bionemo/new_project/exe/bionemo_subpackage.py index 33d3e563f1..8b3ae32780 100644 --- a/internal/infra-bionemo/src/infra_bionemo/new_project/exe/bionemo_subpackage.py +++ b/internal/infra-bionemo/src/infra_bionemo/new_project/exe/bionemo_subpackage.py @@ -81,7 +81,8 @@ def main(*, project_name: str, loc_sub_pack: str, relax_name_check: bool) -> Non check(project_name) internal_deps = [] - for component in ["bionemo-llm", "bionemo-geometric"]: + # UPDATE THIS LIST WITH NEW bionemo-* COMPONENT LIBRARIES! + for component in ["bionemo-llm"]: if ask_yes_or_no(f"🤔 Do you want to depend on {component} ?"): internal_deps.append(f"-e ../{component}") diff --git a/internal/infra-bionemo/tests/test_infra_bionemo/test_new_project/test_cli_tools.py b/internal/infra-bionemo/tests/test_infra_bionemo/test_new_project/test_cli_tools.py index 431694d964..a6a50da713 100644 --- a/internal/infra-bionemo/tests/test_infra_bionemo/test_new_project/test_cli_tools.py +++ b/internal/infra-bionemo/tests/test_infra_bionemo/test_new_project/test_cli_tools.py @@ -13,13 +13,67 @@ # See the License for the specific language governing permissions and # limitations under the License. - import io from pathlib import Path from pytest import raises from infra_bionemo.new_project.exe.bionemo_subpackage import main as main_bionemo_sub +from infra_bionemo.new_project.exe.namespace import main as main_namespace +from infra_bionemo.new_project.exe.simple import main as main_simple + + +def test_create_namespace_cli(tmpdir): + (Path(tmpdir) / "file").touch() + # not a dir! + with raises(ValueError): + main_namespace(namespace="acme", module="rocket", location=f"{str(tmpdir)}/file", no_test_append=False) + (Path(tmpdir) / "file").unlink() + + main_namespace(namespace="acme", module="rocket", location=str(tmpdir), no_test_append=False) + + location = Path(str(tmpdir)) / "acme-rocket" + assert location.is_dir() + assert (location / "src").is_dir() + assert (location / "src" / "acme").is_dir() + assert not (location / "src" / "acme" / "__init__.py").exists() + assert (location / "src" / "acme" / "rocket").is_dir() + assert (location / "src" / "acme" / "rocket" / "__init__.py").is_file() + assert (location / "tests").is_dir() + assert (location / "tests" / "test_acme").is_dir() + assert (location / "tests" / "test_acme" / "test_rocket").is_dir() + assert (location / "tests" / "test_acme" / "test_rocket" / "test_TODO_acme_rocket.py").is_file() + assert (location / "README.md").is_file() + assert not (location / "setup.py").exists() + assert (location / "pyproject.toml").is_file() + assert (location / "requirements.txt").is_file() + assert (location / "requirements-test.txt").is_file() + assert (location / "requirements-dev.txt").is_file() + + +def test_create_simple_cli(tmpdir): + (Path(tmpdir) / "file").touch() + # not a dir! + with raises(ValueError): + main_simple(project_name="simple", location=f"{str(tmpdir)}/file") + (Path(tmpdir) / "file").unlink() + + main_simple(project_name="simple", location=str(tmpdir)) + + location = Path(str(tmpdir)) / "simple" + assert location.is_dir() + assert (location / "src").is_dir() + assert (location / "src" / "simple").is_dir() + assert (location / "src" / "simple" / "__init__.py").is_file() + assert (location / "tests").is_dir() + assert (location / "tests" / "test_simple").is_dir() + assert (location / "tests" / "test_simple" / "test_TODO_simple.py").is_file() + assert (location / "README.md").is_file() + assert not (location / "setup.py").exists() + assert (location / "pyproject.toml").is_file() + assert (location / "requirements.txt").is_file() + assert (location / "requirements-test.txt").is_file() + assert (location / "requirements-dev.txt").is_file() def test_create_bionemo_cli(tmpdir, monkeypatch): @@ -60,10 +114,10 @@ def test_create_bionemo_cli(tmpdir, monkeypatch): relax_name_check=False, ) - (sub_packages / "bionemo-fw" / "requirements.txt").touch(exist_ok=True) + (sub_packages / "bionemo-fw" / "pyproject.toml").touch(exist_ok=True) with monkeypatch.context() as ctx: - ctx.setattr("sys.stdin", io.StringIO("y\ny\n")) + ctx.setattr("sys.stdin", io.StringIO("y")) main_bionemo_sub( project_name="bionemo-supermodel", loc_sub_pack=str(sub_packages), @@ -82,8 +136,8 @@ def test_create_bionemo_cli(tmpdir, monkeypatch): assert (location / "tests" / "bionemo" / "supermodel").is_dir() assert (location / "tests" / "bionemo" / "supermodel" / "test_TODO_bionemo_supermodel.py").is_file() assert (location / "README.md").is_file() - assert (location / "setup.py").is_file() + assert not (location / "setup.py").exists() assert (location / "pyproject.toml").is_file() - assert (location / "requirements.txt").is_file() + assert not (location / "requirements.txt").exists() assert not (location / "requirements-test.txt").exists() assert not (location / "requirements-dev.txt").exists()