Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
TST: adapted tests to modified core code base
Browse files Browse the repository at this point in the history
  • Loading branch information
jotelha committed Feb 4, 2024
1 parent b2287af commit a08d092
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 61 deletions.
5 changes: 2 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def tmp_app_with_users(request):
from dtool_lookup_server.utils import (
register_users,
register_base_uri,
update_permissions,
put_permissions,
)

tmp_mongo_db_name = random_string()
Expand Down Expand Up @@ -76,11 +76,10 @@ def tmp_app_with_users(request):
register_base_uri(base_uri)

permissions = {
"base_uri": base_uri,
"users_with_search_permissions": ["grumpy", "sleepy"],
"users_with_register_permissions": ["grumpy"]
}
update_permissions(permissions)
put_permissions(base_uri, permissions)

@request.addfinalizer
def teardown():
Expand Down
58 changes: 0 additions & 58 deletions tests/test_utils_search_standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,64 +90,6 @@ class _MockApp(object):
# Here are the tests
##############################################################################

def test_lookup_uris(tmp_mongo_db): # NOQA

ds_info_1 = create_dataset_info(
"s3://store1",
"apple-gala",
"---\ndescription: gala apples",
["barrel1", "barrel2"],
["red", "yellow"],
{"type": "fruit"},
"farmer"
)
ds_info_2 = update_base_uri(ds_info_1.copy(), "s3://store2")
uuid = ds_info_1["uuid"]

both_base_uris = ["s3://store1", "s3://store2"]
only_store2 = ["s3://store2"]

mongo_search = MongoSearch()
app = _MockApp()
app.config = {
"SEARCH_MONGO_URI": MONGO_URI,
"SEARCH_MONGO_DB": tmp_mongo_db,
"SEARCH_MONGO_COLLECTION": "datasets"
}
mongo_search.init_app(app)

# Should be empty. Nothing registered yet.
assert mongo_search.lookup_uris(uuid, both_base_uris) == []

# Register a dataset.
mongo_search.register_dataset(ds_info_1)
assert mongo_search.lookup_uris(uuid, both_base_uris) == [
{
"base_uri": ds_info_1["base_uri"],
"name": ds_info_1["name"],
"uri": ds_info_1["uri"],
"uuid": ds_info_1["uuid"]
}
]

# Register the same dataset in different base URI
mongo_search.register_dataset(ds_info_2)
assert len(mongo_search.lookup_uris(uuid, both_base_uris)) == 2 # NOQA

# Make sure only the dataset from store2 is retrievd if limited
# that base URI.
assert mongo_search.lookup_uris(uuid, only_store2) == [
{
"base_uri": ds_info_2["base_uri"],
"name": ds_info_2["name"],
"uri": ds_info_2["uri"],
"uuid": ds_info_2["uuid"]
}
]

# Make sure nothing is returned if there are no base URIs.
assert len(mongo_search.lookup_uris(uuid, [])) == 0 # NOQA


def test_register_basic(tmp_mongo_db): # NOQA

Expand Down

0 comments on commit a08d092

Please sign in to comment.