generated from datalad/datalad-extension-template
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This brings a bunch of fixtures, and also brings in fixtures from datalad-next (including a dependency on it).
- Loading branch information
Showing
10 changed files
with
153 additions
and
117 deletions.
There are no files selected for viewing
This file contains 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 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 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,22 @@ | ||
from datalad.conftest import setup_package | ||
|
||
from datalad_next.tests.fixtures import ( | ||
# no test can leave global config modifications behind | ||
check_gitconfig_global, | ||
# no test can leave secrets behind | ||
check_plaintext_keyring, | ||
# function-scope config manager | ||
datalad_cfg, | ||
# function-scope, Dataset instance | ||
dataset, | ||
# function-scope, Dataset instance with underlying repository | ||
existing_dataset, | ||
) | ||
|
||
from datalad_osf.tests.fixtures import ( | ||
# standard test dataset setup used throughout the datalad-osf tests | ||
minimal_dataset, | ||
osf_credentials, | ||
osf_credentials_or_skip, | ||
osf_node, | ||
) |
This file contains 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,48 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture(autouse=False, scope="function") | ||
def minimal_dataset(existing_dataset): | ||
ds = existing_dataset | ||
(ds.pathobj / 'file1.txt').write_text('content') | ||
(ds.pathobj / 'subdir').mkdir() | ||
(ds.pathobj / 'subdir' / 'file2.txt').write_text('different content') | ||
ds.save() | ||
|
||
yield ds | ||
|
||
|
||
@pytest.fixture(autouse=False, scope="session") | ||
def osf_credentials(): | ||
"""Yields credential dict from get_credentials() suitable of OSF client""" | ||
from datalad_osf.utils import get_credentials | ||
cred = get_credentials(allow_interactive=False) | ||
yield cred | ||
|
||
|
||
@pytest.fixture(autouse=False, scope="function") | ||
def osf_credentials_or_skip(osf_credentials): | ||
if not any(osf_credentials.values()): | ||
pytest.skip(reason='no OSF credentials') | ||
|
||
yield osf_credentials | ||
|
||
|
||
@pytest.fixture(autouse=False, scope="function") | ||
def osf_node(osf_credentials_or_skip): | ||
from datalad_osf.utils import ( | ||
create_node, | ||
delete_node, | ||
) | ||
from osfclient import OSF | ||
osf = OSF(**osf_credentials_or_skip) | ||
|
||
title = 'Temporary DataLad CI project' | ||
category = "data" | ||
|
||
node_id, proj_url = create_node( | ||
osf.session, title, category=category, | ||
) | ||
yield node_id | ||
|
||
delete_node(osf.session, node_id) |
This file contains 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 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 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 |
---|---|---|
|
@@ -11,4 +11,3 @@ | |
def test_register(): | ||
import datalad.api as da | ||
assert hasattr(da, 'create_sibling_osf') | ||
|
Oops, something went wrong.