Exemplo n.º 1
0
    class QueryGetter:
        def __init__(self):
            self.query_handler = QueryHandler()

        def search(self, query_str):
            response = self.query_handler.search_sources(query_str,
                                                         keyed=True,
                                                         incl='omim')
            return response['source_matches'][SourceName.OMIM]
def test_emit_warnings():
    """Test that emit_warnings works correctly."""
    expected_warnings = {
        'nbsp': 'Query contains non breaking space characters.'
    }
    query_handler = QueryHandler()

    # Test emit no warnings
    actual_warnings = query_handler._emit_warnings('CISPLATIN')
    assert actual_warnings is None

    # Test emit warnings
    actual_warnings = query_handler._emit_warnings('CIS PLATIN')
    assert actual_warnings == actual_warnings

    actual_warnings = query_handler._emit_warnings('CIS\u00A0platin')
    assert expected_warnings == actual_warnings

    actual_warnings = query_handler._emit_warnings('CIS platin')
    assert expected_warnings == actual_warnings

    actual_warnings = query_handler._emit_warnings('CIS\xa0platin')
    assert expected_warnings == actual_warnings
Exemplo n.º 3
0
"""Main application for FastAPI"""
from disease import __version__
from disease.query import QueryHandler, InvalidParameterException
from disease.schemas import SearchService, NormalizationService
from fastapi import FastAPI, HTTPException, Query
from fastapi.openapi.utils import get_openapi
import html
from typing import Optional

query_handler = QueryHandler()
app = FastAPI(docs_url='/disease', openapi_url='/disease/openapi.json')


def custom_openapi():
    """Generate custom fields for OpenAPI response"""
    if app.openapi_schema:
        return app.openapi_schema
    openapi_schema = get_openapi(title="The VICC Disease Normalizer",
                                 version=__version__,
                                 openapi_version="3.0.3",
                                 description="Normalize disease terms.",
                                 routes=app.routes)
    #    openapi_schema['info']['license'] = {  # TODO
    #        "name": "Name-of-license",
    #        "url": "http://www.to-be-determined.com"
    #    }
    openapi_schema['info']['contact'] = {
        "name": "Alex H. Wagner",
        "email": "*****@*****.**"
    }
    app.openapi_schema = openapi_schema
Exemplo n.º 4
0
 def __init__(self):
     self.query_handler = QueryHandler()