예제 #1
0
파일: test_api.py 프로젝트: jjmurre/GOB-API
def test_collection_with_view(monkeypatch):
    global mockRequest
    global catalog, collection
    global entities, entity

    before_each_api_test(monkeypatch)

    from gobapi.api import _collection
    assert (_collection('catalog',
                        'collection') == 'catalog.collection not found')

    catalog = 'catalog'
    collection = 'collection'

    mockRequest.args = {'view': 'enhanced'}
    MockGOBViews.views = {}
    assert (_collection(
        'catalog',
        'collection') == 'catalog.collection?view=enhanced not found')

    MockGOBViews.views = {'enhanced': {'name': 'the_view_name'}}
    # Views always show 1 page extra because count is slow on large views
    assert (_collection('catalog', 'collection') == (({
        'page_size': 100,
        'pages': 1,
        'results': [],
        'total_count': 0
    }, {
        'next': None,
        'previous': None
    }), 200, {
        'Content-Type':
        'application/json'
    }))
예제 #2
0
파일: test_api.py 프로젝트: jjmurre/GOB-API
    def test_collection(self, mock_gobmodel, mock_query, mock_stream,
                        mock_ndjson):
        mock_gobmodel = MockGOBModel
        mock_query.side_effect = lambda cat, col, view: ([], lambda e: e)

        mockRequest.args = {'stream': 'true'}
        result = _collection('catalog', 'collection')
        mock_stream.assert_called()

        mockRequest.args = {'ndjson': 'true'}
        result = _collection('catalog', 'collection')
        mock_ndjson.assert_called()
예제 #3
0
파일: test_api.py 프로젝트: jjmurre/GOB-API
def test_collection(monkeypatch):
    global mockRequest
    global catalog, collection
    global entities, entity

    before_each_api_test(monkeypatch)

    from gobapi.api import _collection
    assert (_collection('catalog',
                        'collection') == 'catalog.collection not found')

    catalog = 'catalog'
    collection = 'collection'

    mockRequest.args = {}
    assert (_collection('catalog', 'collection') == (({
        'page_size': 100,
        'pages': 0,
        'results': [],
        'total_count': 0
    }, {
        'next': None,
        'previous': None
    }), 200, {
        'Content-Type':
        'application/json'
    }))

    mockRequest.args = {'page': 5, 'page_size': 10}
    assert (_collection('catalog', 'collection') == (({
        'page_size': 10,
        'pages': 0,
        'results': [],
        'total_count': 0
    }, {
        'next': None,
        'previous': None
    }), 200, {
        'Content-Type':
        'application/json'
    }))