Skip to content

Commit

Permalink
restore CLI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmgreaves committed Nov 1, 2024
1 parent e3c640e commit dcbcf8e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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),
Expand All @@ -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()

0 comments on commit dcbcf8e

Please sign in to comment.