Skip to content
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

Rework Shulker Box Folder Settings #118

Merged
merged 5 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Yeah! Let's use that placement cache!
  • Loading branch information
OpenBagTwo committed Nov 16, 2023
commit 2b9d573ba407ccec42a0e15f47bd1827496f5b8e
46 changes: 45 additions & 1 deletion enderchest/test/test_craft.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

from enderchest import EnderChest, ShulkerBox, craft
from enderchest import filesystem as fs
from enderchest.enderchest import _DEFAULTS, create_ender_chest
from enderchest.enderchest import create_ender_chest
from enderchest.gather import load_ender_chest
from enderchest.place import place_ender_chest

from . import utils

Expand Down Expand Up @@ -358,6 +359,49 @@ def test_warns_if_you_forgot_to_add_yourself_as_the_host(
in warn_log
)

def test_global_box_links_nested_litematica_folder(
self, monkeypatch, minecraft_root, home, capsys, caplog
):
utils.pre_populate_enderchest(minecraft_root / "EnderChest")

script_reader = utils.scripted_prompt(
[
"F",
"",
"",
"",
"",
"",
"",
"G",
"-100",
"",
"", # this is the final writeme confirmation
]
)
monkeypatch.setattr("builtins.input", script_reader)

craft.create_shulker_box(
minecraft_root,
craft.specify_shulker_box_from_prompt(minecraft_root, "olam"),
(), # sneakily testing that it'll create parent dirs
)

resource_path = (
Path("config") / "litematica" / "material_list_2023-11-16_15.43.17.txt"
)

(fs.shulker_box_root(minecraft_root, "olam") / resource_path).write_text(
"lots of TNT\n"
)

placements = place_ender_chest(minecraft_root)

assert (
placements["axolotl"].get(resource_path, []),
placements["axolotl"][resource_path.parent],
) == ([], ["olam"])


class TestPromptByFilter:
def test_giving_default_responses_results_in_the_expected_shulker_box(
Expand Down
6 changes: 3 additions & 3 deletions enderchest/test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def populate_instances_folder(instances_folder: Path) -> None:

def pre_populate_enderchest(
enderchest_folder: Path,
*shulkers: tuple[str, str],
*boxes: tuple[str, str],
) -> list[ShulkerBox]:
"""Create an EnderChest folder, pre-populated with the testing enderchest.cfg
folder and the specified shulker boxes
Expand All @@ -234,7 +234,7 @@ def pre_populate_enderchest(
----------
enderchest_folder : Path
The path of the EnderChest folder
*shulkers : 2-tuple of str
*boxes : 2-tuple of str
Shulker boxes to populate, with tuple members of:
- name : the folder name of the shulker
- config : the contents of the config file
Expand All @@ -249,7 +249,7 @@ def pre_populate_enderchest(
with as_file(testing_files.ENDERCHEST_CONFIG) as config_file:
shutil.copy(config_file, enderchest_folder)
shulker_boxes: list[ShulkerBox] = []
for shulker_name, shulker_config in shulkers:
for shulker_name, shulker_config in boxes:
(enderchest_folder / shulker_name).mkdir(parents=True, exist_ok=True)
config_path = enderchest_folder / shulker_name / fs.SHULKER_BOX_CONFIG_NAME
with config_path.open("w") as config_file:
Expand Down