Skip to content

Commit

Permalink
Merge branch 'minor-fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
JWCook committed Jan 10, 2024
2 parents 4e19a7a + 815d35b commit e562524
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pyinaturalist/request_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ def convert_pagination_params(params: RequestParams) -> RequestParams:
params['per_page'] = 0
if params.pop('reverse', False) is True:
params['order'] = 'descending'
if params.get('page') is not None and params['page'] < 1:
raise ValueError('Page number must be a positive integer')
return params


Expand Down
2 changes: 1 addition & 1 deletion scripts/observation_crud_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def create_test_obs(client: iNatClient):

def update_test_obs(client, test_obs_id):
response = client.observations.upload(test_obs_id, photos=SAMPLE_PHOTO)
photo_id = response[0].get('photo').get('id')
photo_id = response[0].id
assert photo_id
logger.info(f'Added photo to observation: {photo_id}')

Expand Down
3 changes: 3 additions & 0 deletions test/test_request_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def test_convert_pagination_params():
assert params['order'] == 'descending'
assert 'reverse' not in params

with pytest.raises(ValueError):
convert_pagination_params({'page': 0})


@pytest.mark.parametrize(
'start, end, interval',
Expand Down

0 comments on commit e562524

Please sign in to comment.