Skip to content

Commit

Permalink
Add test to check all versions being used have processing availble
Browse files Browse the repository at this point in the history
  • Loading branch information
Tehsurfer committed Nov 24, 2023
1 parent 0885728 commit a499114
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/scicrunch_process_results.py
Expand Up @@ -3,7 +3,6 @@
import re
from app.config import Config
from flask import jsonify
from os import listdir
from app.scicrunch_processing_common import SKIPPED_OBJ_ATTRIBUTES


Expand Down Expand Up @@ -112,6 +111,7 @@ def reform_dataset_results(results):
for kb_result in kb_results:
try:
version = kb_result['version']
version = convert_patch_to_X(version)
except KeyError:
# Try to get minimal information out from the datasets
version = 'undefined'
Expand Down
19 changes: 19 additions & 0 deletions tests/test_scicrunch.py
Expand Up @@ -2,10 +2,13 @@
import pytest
import re
from packaging import version
import requests
from os import listdir

from app import app
from app.main import dataset_search
from app.scicrunch_requests import create_query_string
from app.config import Config

from known_uberons import UBERONS_DICT
from known_dois import has_doi_changed, warn_doi_changes
Expand All @@ -18,11 +21,27 @@ def client():
return app.test_client()



def test_scicrunch_keys(client):
r = client.get('/search/')
assert r.status_code == 200
assert 'numberOfHits' in json.loads(r.data).keys()

def test_scicrunch_versions_are_supported():
r = requests.get(f'{Config.SCI_CRUNCH_HOST}/_search?api_key={Config.KNOWLEDGEBASE_KEY}&q=""')
results = r.json()
hits = results['hits']['hits']
available_versions = listdir('../app/')
for i, hit in enumerate(hits):
try:
version = hit['_source']['item']['version']['keyword'][:-1] + 'X'
except KeyError:
# Try to get minimal information out from the datasets
version = 'undefined'

package_version = f'scicrunch_processing_v_{version.replace(".", "_")}'
assert package_version in available_versions


def check_doi_status(client, dataset_id, doi):
r = client.get('/dataset_info/using_pennsieve_identifier', query_string={'identifier': dataset_id})
Expand Down

0 comments on commit a499114

Please sign in to comment.