コード例 #1
0
ファイル: controller.py プロジェクト: colleenXu/smartAPI
    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
ファイル: controller.py プロジェクト: colleenXu/smartAPI
    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
ファイル: test_controller.py プロジェクト: colleenXu/smartAPI
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
ファイル: test_model.py プロジェクト: colleenXu/smartAPI
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')