Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed Nov 16, 2023
1 parent 83d2570 commit e197b0f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 8 deletions.
32 changes: 28 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,10 @@ def persistent_repository(tmpdir_factory):


@pytest.fixture(scope='module', autouse=False)
def private_and_non_existing_repository():
r"""Private, public and non-existing Artifactory repositories.
def private_and_public_repository():
r"""Private and public repository on Artifactory.
Configure the following repositories:
* non-existing: non-exsiting repo on public Artifactory
* data-private: repo on public Artifactory without access
* data-public: repo on public Artifactory with anonymous access
Expand All @@ -193,7 +192,6 @@ def private_and_non_existing_repository():
backend = 'artifactory'
current_repositories = audb.config.REPOSITORIES
audb.config.REPOSITORIES = [
audb.Repository('non-existing', host, backend),
audb.Repository('data-private', host, backend),
audb.Repository('data-public', host, backend),
]
Expand All @@ -203,6 +201,32 @@ def private_and_non_existing_repository():
audb.config.REPOSITORIES = current_repositories


@pytest.fixture(scope='module', autouse=False)
def non_existing_repository():
r"""Non-existing repository on Artifactory.
Configure the following repositories:
* non-existing: non-exsiting repo on public Artifactory
* data-public: repo on public Artifactory with anonymous access
Note, that the order of the repos is important.
audb will visit the repos in the given order
until it finds the requested database.
"""
host = 'https://audeering.jfrog.io/artifactory'
backend = 'artifactory'
current_repositories = audb.config.REPOSITORIES
audb.config.REPOSITORIES = [
audb.Repository('non-existing', host, backend),
audb.Repository('data-public', host, backend),
]

yield repository

audb.config.REPOSITORIES = current_repositories


@pytest.fixture(scope='package', autouse=True)
def hide_default_repositories():
r"""Hide default audb repositories during testing."""
Expand Down
25 changes: 21 additions & 4 deletions tests/test_backend.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
import audb


def test_visiting_backends(private_and_non_existing_repository):
r"""Tests visiting several backends when looking for a database.
def test_visiting_repos(private_and_public_repository):
r"""Tests visiting several repos when looking for a database.
When requesting a database,
audb needs to look for it
in every repository on the corresponding backend.
This should not fail,
even when the user has no access rights,
or the repo does not exist.
even when the user has no access rights.
"""
audb.load(
'emodb',
version='1.4.1',
only_metadata=True,
verbose=False,
)


def test_visiting_non_existing_repos(non_existing_repository):
r"""Tests visiting non-existing backends when looking for a database.
When requesting a database,
audb needs to look for it
in every repository on the corresponding backend.
This should not fail,
even when the user has no access rights.
"""
audb.load(
Expand Down

0 comments on commit e197b0f

Please sign in to comment.