Skip to content

Commit

Permalink
Merge pull request #67 from datalad/fixture-tree
Browse files Browse the repository at this point in the history
Add 'populated_dataset' fixture as alternative to 'populate_dataset' helper
  • Loading branch information
adswa committed Sep 21, 2023
2 parents 8b76391 + c804f5d commit 2fa07f7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
3 changes: 2 additions & 1 deletion datalad_ria/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
]

from .tests.fixtures import (
common_ora_init_opts,
populated_dataset,
ria_sshserver,
ria_sshserver_setup,
common_ora_init_opts,
)
18 changes: 18 additions & 0 deletions datalad_ria/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
assert_ssh_access,
)

from datalad_next.tests.utils import create_tree


@pytest.fixture(autouse=False, scope="session")
def ria_sshserver_setup(tmp_path_factory):
Expand Down Expand Up @@ -77,6 +79,22 @@ def ria_sshserver(ria_sshserver_setup, datalad_cfg, monkeypatch):
yield ria_baseurl, ria_sshserver_setup['LOCALPATH']


@pytest.fixture(autouse=False, scope="function")
def populated_dataset(existing_dataset):
"""Creates a new dataset with saved payload"""
tree = {
'one.txt': 'content1',
'three.txt': 'content3',
'subdir': {
'two': 'content2',
'four': 'content4',
},
}
create_tree(existing_dataset.path, tree, archives_leading_dir=False)
existing_dataset.save(result_renderer='disabled')
yield existing_dataset


@pytest.fixture(autouse=False, scope="function")
def common_ora_init_opts():
"""Return common initialization arguments for the ora special remote"""
Expand Down
13 changes: 12 additions & 1 deletion datalad_ria/tests/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ def test_riaserver_fixture(ria_sshserver):
assert ria_sshserver[0].startswith('ria+ssh://')


def test_populate_dataset_fixture(populated_dataset):
# populated_dataset is a Dataset object
assert populated_dataset.pathobj.exists()
assert (populated_dataset.pathobj / 'three.txt').exists()
with open(populated_dataset.pathobj / 'three.txt') as file:
payload = file.read()
assert payload == "content3"
assert (populated_dataset.pathobj / 'subdir').is_dir()


def test_common_ora_init_opts_fixture(common_ora_init_opts):
assert "externaltype=ora" in common_ora_init_opts
assert "autoenable=true" in common_ora_init_opts
assert "autoenable=true" in common_ora_init_opts

0 comments on commit 2fa07f7

Please sign in to comment.