From 73bee26b3e8164567a0f5abd6d65b858a632c847 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 13 May 2019 10:42:44 -0400 Subject: [PATCH] SIP Fines/fees retrieval test Signed-off-by: Bill Erickson --- KCLS/test-scripts/sip/sip-fines.py | 64 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 KCLS/test-scripts/sip/sip-fines.py diff --git a/KCLS/test-scripts/sip/sip-fines.py b/KCLS/test-scripts/sip/sip-fines.py new file mode 100755 index 0000000000..3a58195725 --- /dev/null +++ b/KCLS/test-scripts/sip/sip-fines.py @@ -0,0 +1,64 @@ +#!/usr/bin/python3 +# ----------------------------------------------------------------------- +# Copyright (C) 2015 King County Library System +# Bill Erickson +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# ----------------------------------------------------------------------- + +# ----------------------------------------------------------------------- +# Sends a series of read-only requests (item info, patron info, etc.) +# to the configured SIP server. It does not send any requests which +# modify data on the server (checkouts, etc.) +# ----------------------------------------------------------------------- +import sys, logging, logging.config, getopt, configparser +import pysip2.client + +logging.config.fileConfig('pysip2-client.ini') +config = configparser.ConfigParser() +config.read('pysip2-client.ini') + +server = config['client']['server'] +port = config['client']['port'] +institution = config['client']['institution'] +username = config['client']['username'] +password = config['client']['password'] +location_code = config['client']['location_code'] + +client = pysip2.client.Client(server, int(port)) +client.default_institution = institution + +logging.info("connecting to " + server) +try: + client.connect() +except Exception as err: + logging.error("Unable to connect to server %s : %s" % (server, str(err))) + sys.exit(1) + +logging.info("logging in as " + username) +if not client.login(username, password, location_code): + logging.error("Login failed for %s @ %s" % (username, server)) + sys.exit(1) + +stat = client.sc_status() +if stat.fixed_fields[0].value == 'Y': + logging.info("SIP server is online") +else: + logging.info("Status message reports SIP server is NOT online") + +# patron information requests +for barcode in config['test-data']['patron_info_barcodes'].split(','): + + resp = client.patron_info_request(barcode, summary = ' Y ') + logging.info(repr(resp)) + +client.disconnect() +client.log_summary() -- 2.11.0