"""Integration tests for ows-accounting: holds/active.""" from tests.integration import conftest from tests.integration.conftest import basic_headers def test_holds_active(): """Holds/active endpoint should return the list of active accounting holds""" ows_accounting_client = conftest.ows_accounting_api_client(basic_headers()) params = {"limit": 10, "offset": 5} results = ows_accounting_client.get_holds_active(params) assert results.status_code == 200, \ 'Result of call was {}, expected 200.'.format(results.status_code) json_results = results.json() assert json_results['pagination']['limit'] == params['limit'] assert json_results['pagination']['offset'] == params['offset'] assert len(json_results['items']) == params['limit'], \ "Endpoint returned different amount of results: {}, " \ "requested: {}".format(len(json_results['items']), params['limit']) def test_holds_active_by_vendor(): """Holds/active endpoint should return the list of active accounting holds for specific vendors""" ows_accounting_client = conftest.ows_accounting_api_client(basic_headers()) vendor_ids = ['1', '2', '3'] params = {'vendor_ids': ','.join(vendor_ids)} results = ows_accounting_client.get_holds_active(params) assert results.status_code == 200, \ 'Result of call was {}, expected 200.'.format(results.status_code) json_results = results.json() vendor_ids_from_response = list( map(lambda i: str(i['vendor_id']), json_results['items'])) assert set(vendor_ids) == set(vendor_ids_from_response)