Пример #1
0
    def exists(cls, _id):
        """
        If a SmartAPI document exists in database.
        Do NOT fully rely on this for other operations.
        """
        # Data can change in between calls.
        # Use try-catch blocks in follow up ops.

        return bool(APIDoc.exists(_id))
Пример #2
0
    def find(cls, val, field='slug'):
        """
        Find a SmartAPI by a field other than _id.
        Return the first _id or None if no match.
        """
        # Data can change in between calls.
        # Use try-catch blocks in follow up ops.

        if field in ('slug', 'username', 'url'):
            field = '_meta.' + field

        return APIDoc.exists(val, field)
Пример #3
0
def test_delete(myvariant):

    mv = SmartAPI.get(myvariant)
    mv.delete()

    refresh()

    assert not APIDoc.exists(myvariant)

    URL = "http://example.com/valid.json"
    with open(os.path.join(dirname, './validate/openapi-pass.json'), 'rb') as file:
        smartapi = SmartAPI(URL)
        smartapi.raw = file.read()
        with pytest.raises(NotFoundError):
            smartapi.delete()
Пример #4
0
def test_exists():
    # info.title : "MyDisease.info API"
    assert not APIDoc.exists('doc0')
    assert APIDoc.exists('doc1')
    assert APIDoc.exists('3.0.0', 'openapi')
    assert APIDoc.exists('mygene', '_meta.slug')
    assert not APIDoc.exists('mygene', 'info.title')
    assert APIDoc.exists('mygene.info', 'info.title')
    assert APIDoc.exists('mygene.info api', 'info.title')
    assert APIDoc.exists('api', 'info.title')
    assert not APIDoc.exists('mygene', 'info.title.raw')
    assert not APIDoc.exists('mygene.info', 'info.title.raw')
    assert not APIDoc.exists('mygene.info api', 'info.title.raw')
    assert not APIDoc.exists('api', 'info.title.raw')
    assert APIDoc.exists('MyGene.info API', 'info.title.raw')
    assert APIDoc.exists('mygene.info', 'info.description')