Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Oct 15, 2024
1 parent 8739c99 commit ab26e77
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
3 changes: 1 addition & 2 deletions empack/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import sys
from pathlib import Path, PosixPath, PureWindowsPath
from tempfile import TemporaryDirectory
from typing import Optional
from typing import Optional, Callable

from appdirs import user_cache_dir
from traitlets import Callable

from .filter_env import filter_env, filter_pkg, iterate_env_pkg_meta
from .micromamba_wrapper import create_environment
Expand Down
40 changes: 40 additions & 0 deletions tests/test_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,46 @@ def test_pack_env(tmp_path, packages, relocate_prefix):
pkg_meta = json.load(meta)
assert pkg_info["name"] == pkg_meta["name"]

def test_pack_env_with_url(tmp_path):
# create the env at the temporary location
packages = 'numpy'
relocate_prefix = '/'
prefix = tmp_path / "env"

create_environment(
prefix=prefix,
packages=packages,
channels=CHANNELS,
relocate_prefix=relocate_prefix,
platform="emscripten-wasm32",
)
def url_factory(pkg):
return f'http://localhost:1234/{pkg["filename"]}'
pack_env(
env_prefix=prefix,
outdir=tmp_path,
use_cache=False,
compression_format="gz",
relocate_prefix=relocate_prefix,
file_filters=FILE_FILTERS,
compresslevel=1,
package_url_factory=url_factory
)

# check that there is a json with all the packages
env_metadata_json_path = tmp_path / "empack_env_meta.json"
assert env_metadata_json_path.exists()

# check that json file contains all packages
with open(env_metadata_json_path) as f:
env_metadata = json.load(f)
packages_metadata = env_metadata["packages"]

# check that there is a tar.gz file for each package
for pkg_info in packages_metadata:
assert 'http://localhost:1234' in pkg_info["url"]



@pytest.mark.parametrize("mount_dir", ["/some", "/some/", "/some/nested", "/"])
def test_pack_directory(tmp_path, mount_dir):
Expand Down

0 comments on commit ab26e77

Please sign in to comment.