Skip to content

Commit

Permalink
fix: schemes option is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
01Joseph-Hwang10 committed May 15, 2024
1 parent b7028c0 commit f239785
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 23 deletions.
2 changes: 1 addition & 1 deletion ldm/api/config/_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@


class DependencyConfig(BaseModel):
schemes: dict[str, SchemeConfig]
schemes: dict[str, SchemeConfig] | None = Field(default_factory=lambda: {})
dependencies: dict[str, str]
config: InstallerConfig | None = Field(default_factory=lambda: InstallerConfig())
Empty file added tests/empty/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions tests/empty/project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!ldm.yml
!.gitignore
1 change: 1 addition & 0 deletions tests/empty/project/ldm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dependencies: {}
13 changes: 13 additions & 0 deletions tests/empty/test_ldm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import shutil
from os.path import dirname, join
from ..helpers import run_ldm_install

PROJECT_ROOT = join(dirname(__file__), "project")


def setup_module():
shutil.rmtree(join(PROJECT_ROOT, "src"), ignore_errors=True)


def test_ldm_empty_config():
assert run_ldm_install(cwd=PROJECT_ROOT)
13 changes: 13 additions & 0 deletions tests/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import subprocess


def run_ldm_install(
args: list[str] | None = None,
*,
cwd: str,
):
return subprocess.check_output(
f"ldm install {' '.join(args or [])}",
shell=True,
cwd=cwd,
)
3 changes: 3 additions & 0 deletions tests/parallel/project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!ldm.yml
!.gitignore
14 changes: 3 additions & 11 deletions tests/parallel/test_ldm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import shutil
import subprocess
from os.path import dirname, exists, join
from ..helpers import run_ldm_install

PROJECT_ROOT = join(dirname(__file__), "project")

Expand All @@ -12,23 +12,15 @@ def setup_module():

@pytest.mark.order(1)
def test_ldm_specified_targets():
_run_ldm_install(["clamp"])
assert run_ldm_install(["clamp"], cwd=PROJECT_ROOT)

assert exists(join(PROJECT_ROOT, "src/utils/clamp.ts"))
assert not exists(join(PROJECT_ROOT, "src/styles/reset.css"))


@pytest.mark.order(2)
def test_ldm_parallel_option():
_run_ldm_install()
assert run_ldm_install(cwd=PROJECT_ROOT)

assert exists(join(PROJECT_ROOT, "src/utils/clamp.ts"))
assert exists(join(PROJECT_ROOT, "src/styles/reset.css"))


def _run_ldm_install(args: list[str] | None = None):
return subprocess.check_output(
f"ldm install {' '.join(args or [])}",
shell=True,
cwd=PROJECT_ROOT,
)
3 changes: 3 additions & 0 deletions tests/sequential/project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!ldm.yml
!.gitignore
14 changes: 3 additions & 11 deletions tests/sequential/test_ldm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import shutil
import subprocess
from os.path import dirname, exists, join
from ..helpers import run_ldm_install

PROJECT_ROOT = join(dirname(__file__), "project")

Expand All @@ -12,23 +12,15 @@ def setup_module():

@pytest.mark.order(1)
def test_ldm_specified_targets():
_run_ldm_install(["clamp"])
assert run_ldm_install(["clamp"], cwd=PROJECT_ROOT)

assert exists(join(PROJECT_ROOT, "src/utils/clamp.ts"))
assert not exists(join(PROJECT_ROOT, "src/styles/reset.css"))


@pytest.mark.order(2)
def test_ldm_sequential_option():
_run_ldm_install()
assert run_ldm_install(cwd=PROJECT_ROOT)

assert exists(join(PROJECT_ROOT, "src/utils/clamp.ts"))
assert exists(join(PROJECT_ROOT, "src/styles/reset.css"))


def _run_ldm_install(args: list[str] | None = None):
return subprocess.check_output(
f"ldm install {' '.join(args or [])}",
shell=True,
cwd=PROJECT_ROOT,
)

0 comments on commit f239785

Please sign in to comment.