Skip to content

Commit

Permalink
location: add test to increase code coverage
Browse files Browse the repository at this point in the history
* Adds test to increase location code coverage to test `extended_validation` function.

Co-Authored-by: Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
zannkukai committed Apr 15, 2020
1 parent 708de39 commit 686cfbb
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/api/test_locations_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
"""Tests REST API locations."""

import json
from copy import deepcopy

import mock
import pytest
from flask import url_for
from invenio_accounts.testutils import login_user_via_session
from utils import VerifyRecordPermissionPatch, get_json, postdata, \
to_relative_url

from rero_ils.modules.errors import RecordValidationError


def test_locations_permissions(client, loc_public_martigny, json_header):
"""Test record retrieval."""
Expand Down Expand Up @@ -247,10 +251,23 @@ def test_location_secure_api_create(client, lib_fully, lib_martigny,
system_librarian_martigny_no_email,
system_librarian_sion_no_email):
"""Test location secure api create."""
# Martigny
# try to create a pickup location without pickup location name. This should
# be failed due to `extended_validation` rules
login_user_via_session(client, librarian_martigny_no_email.user)
post_entrypoint = 'invenio_records_rest.loc_list'
fake_location_data = deepcopy(loc_public_martigny_data)
del fake_location_data['pid']
if 'pickup_name' in fake_location_data:
del fake_location_data['pickup_name']
fake_location_data['is_pickup'] = True
with pytest.raises(RecordValidationError):
res, _ = postdata(
client,
post_entrypoint,
fake_location_data
)

# Martigny
del loc_public_martigny_data['pid']
res, _ = postdata(
client,
Expand Down

0 comments on commit 686cfbb

Please sign in to comment.