Esempio n. 1
0
def test_siren_raw_search():

    criteria = Criteria.Raw('unitePurgeeUniteLegale:True')
    request = api.siren(q=criteria)
    results = request.get()

    assert results['header']['statut'] == 200
    assert request.url == base_siren_url + '/?q=unitePurgeeUniteLegale:True'
Esempio n. 2
0
def test_request_csv_fail_with_cursor(execute_request):

    request = api.siren(Criteria.Raw('*'))
    request.format = 'csv'

    assert request.header['Accept'] == 'text/csv'

    with pytest.raises(RequestExeption):
        pages = request.pages()
        first = next(pages)
Esempio n. 3
0
def test_request_iterate_on_pages(api, execute_request):

    request = api.siren(Criteria.Raw('*'))

    cursors = []

    for (index, page) in enumerate(request.pages()):
        cursors.append(page['header']['curseur'])
        if len(cursors) > 2: break

    assert cursors[0] != cursors[1] and cursors[1] != cursors[2]
Esempio n. 4
0
def test_request_first_pages(api, execute_request):

    request = api.siren(Criteria.Raw('*'))

    pages = request.pages()
    first = next(pages)

    print(first['header'])

    assert first['header']['statut'] == 200
    assert first['header']['curseur'] == '*'
    assert first['header']['curseurSuivant']
Esempio n. 5
0
    def set_url_params(self, name, value):

        if isinstance(value, dict):
            criteria = Criteria.List(
                *
                [Criteria.Field(key, value)
                 for (key, value) in value.items()]).toURLParams()

        elif isinstance(value, list) or \
             isinstance(value, tuple):
            criteria = Criteria.List(*value).toURLParams()

        elif isinstance(value, str) or \
             isinstance(value, int) or \
             isinstance(value, float):
            criteria = Criteria.Raw(str(value)).toURLParams()

        elif isinstance(value, Criteria.Base):
            criteria = value.toURLParams()

        else:
            raise Exception

        self._url_params[name] = criteria