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

Fix creation of intermediate groups #122

Merged
merged 3 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions exdir/core/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ def create_group(self, name):
path = utils.path.name_to_asserted_group_path(name)
if len(path.parts) > 1:
subgroup = self.require_group(path.parent)
subgroup.create_group(path.name)
return
return subgroup.create_group(path.name)

exob._assert_valid_name(path, self)

Expand Down
10 changes: 7 additions & 3 deletions tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,21 @@ def test_create_existing_twice(exdir_tmpfile):
exdir_tmpfile.create_group("test")


# TODO update this test when it is implemented
def test_create_intermediate(setup_teardown_file):
"""intermediate groups can be created automatically."""
f = setup_teardown_file[3]
grp = f.create_group("test")

grp.create_group("foo/bar/baz")
grp2 = grp.create_group("foo/bar/baz")

assert isinstance(grp["foo/bar/baz"], Group)
assert isinstance(grp2, Group)

# assert grp.name == "/foo/bar/baz"
assert grp2.name == "/test/foo/bar/baz"
assert "foo" in grp
assert "bar" in grp.require_group("foo")
assert "baz" in grp.require_group("foo").require_group("bar")
assert grp.require_group("foo").require_group("bar").require_group("baz") == grp2


def test_create_exception(setup_teardown_file):
Expand Down