-
Notifications
You must be signed in to change notification settings - Fork 4
Test updates: stabler debup hash and cli integration coverage #462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
657a1cf
normalize data order before hashing and tests
rugeli fefc984
test pack cli
rugeli 1657cc0
refactor test file: use tmp_path instead of writing to a working dir
rugeli b5ca2f7
cleanup
rugeli b84f1f1
formatting
rugeli aeb65e2
add recipe fixture
rugeli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| """ | ||
| Integration tests for the `pack` CLI entry point (`cellpack/bin/pack.py`). | ||
|
|
||
| Two input types are covered: | ||
|
|
||
| 1. A string file path — the existing local CLI workflow invoked as | ||
| `pack -r RECIPE_PATH -c CONFIG_PATH`. Accepting a recipe dict must not change anything about this | ||
| path. | ||
|
|
||
| 2. A json dict — the new flow used by the docker server's | ||
| `pack_handler` when it receives a json body. The dict must flow | ||
| through `RecipeLoader` and the rest of the pipeline remains the same to a | ||
| recipe loaded. | ||
|
|
||
| The packing config can be supplied as a file path or omitted entirely, in | ||
| which case `ConfigLoader` falls back to its built-in default values. | ||
| """ | ||
|
|
||
| import json | ||
| from pathlib import Path | ||
| import copy | ||
| import pytest | ||
|
|
||
| from cellpack.bin.pack import pack | ||
|
|
||
| _RECIPE = { | ||
| "version": "1.0.0", | ||
| "format_version": "2.0", | ||
| "name": "test_pack_cli", | ||
| "bounding_box": [[0, 0, 0], [50, 50, 1]], | ||
| "objects": { | ||
| "sphere_5": { | ||
| "type": "single_sphere", | ||
| "radius": 5, | ||
| "max_jitter": [1, 1, 0], | ||
| "place_method": "jitter", | ||
| } | ||
| }, | ||
| "composition": { | ||
| "space": {"regions": {"interior": ["A"]}}, | ||
| "A": {"object": "sphere_5", "count": 1}, | ||
| }, | ||
| } | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def recipe_data(): | ||
| # RecipeLoader mutates the dict it receives, so each test gets a fresh copy to stay independent of run order. | ||
| return copy.deepcopy(_RECIPE) | ||
|
|
||
|
|
||
| def _write_config(tmp_path: Path) -> Path: | ||
| config = { | ||
| "name": "test_pack_cli", | ||
| "out": f"{tmp_path}/", | ||
| "place_method": "jitter", | ||
| "inner_grid_method": "raytrace", | ||
| "save_analyze_result": False, | ||
| "save_plot_figures": False, | ||
| "number_of_packings": 1, | ||
| "show_progress_bar": False, | ||
| "load_from_grid_file": False, | ||
| } | ||
| config_path = tmp_path / "config.json" | ||
| config_path.write_text(json.dumps(config)) | ||
| return config_path | ||
|
|
||
|
|
||
| def test_pack_with_recipe_path(tmp_path, recipe_data): | ||
| recipe_path = tmp_path / "recipe.json" | ||
| recipe_path.write_text(json.dumps(recipe_data)) | ||
| config_path = _write_config(tmp_path) | ||
| pack(recipe=str(recipe_path), config_path=str(config_path)) | ||
|
|
||
|
|
||
| def test_pack_with_recipe_dict(tmp_path, recipe_data): | ||
| """ | ||
| `pack()` also accepts a recipe dict directly, so | ||
| the docker server can forward a parsed JSON body without writing it to | ||
| db first. | ||
| """ | ||
| config_path = _write_config(tmp_path) | ||
| pack(recipe=recipe_data, config_path=str(config_path)) | ||
|
|
||
|
|
||
| def test_pack_with_default_config(tmp_path, monkeypatch, recipe_data): | ||
| """Omitting `config_path` falls back to `ConfigLoader.default_values`.""" | ||
| # default `out: "out/"` is relative, monkeypatch.chdir keeps outputs inside tmp_path. | ||
| monkeypatch.chdir(tmp_path) | ||
| pack(recipe=recipe_data) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit out of scope but a simple change, switched tests to write via
tmp_pathso they leave no trace liketest_file.txtin the repo root