-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathintegration_test.py
81 lines (73 loc) · 2.86 KB
/
integration_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"""This is a simple integration test class. Run it with
some credentials and it will try to fetch things for you."""
import argparse
import datetime
import json
from folioclient import FolioClient
def main():
parser = argparse.ArgumentParser()
parser.add_argument("okapi_url", help=("OKAPI base url"))
parser.add_argument("tenant_id", help=("id of the FOLIO tenant."))
parser.add_argument("username", help=("the api user"))
parser.add_argument("password", help=("the api users password"))
args = parser.parse_args()
print("\tOkapi URL:\t", args.okapi_url)
print("\tTenanti Id:\t", args.tenant_id)
print("\tUsername:\t", args.username)
print("\tPassword:\tSecret")
folio_client = FolioClient(args.okapi_url, args.tenant_id, args.username, args.password)
version = folio_client.get_module_version("mod-inventory-storage")
exact_schema = folio_client.get_from_github(
"folio-org", "mod-inventory-storage", "/ramls/instance.json"
)
print(json.dumps(exact_schema))
a = folio_client.get_instance_json_schema()
assert a
b = folio_client.get_item_schema()
assert b
c = folio_client.get_holdings_schema()
assert c
d = folio_client.get_user_schema()
assert d
statistical_codes = list(
folio_client.folio_get_all(
"/statistical-codes", "statisticalCodes", "?query=cql.allRecords=1", 1000
)
)
print(f"{len(statistical_codes)} \tstatistical_codes")
print(f"Found {len(list(folio_client.locations))} locations")
print(f"Found {len(list(folio_client.identifier_types))} identifier_types")
item_loan_types = folio_client.get_all_ids("/loan-types")
print(f"Fetched {len(list(item_loan_types))} item loan types")
random_users = folio_client.get_random_objects("/users", 10, "")
print(f"Fetched {len(list(random_users))} random users")
print(folio_client.current_user)
print(folio_client.get_metadata_construct())
# print(len(folio_client.folio_get_all("/circulation/requests")))
print([t["name"] for t in folio_client.alt_title_types])
print(
[
t["name"]
for t in folio_client.folio_get_all(
"/alternative-title-types", "alternativeTitleTypes"
)
]
)
df = "%Y-%m-%dT%H:%M:%S.%f+0000"
"""bc = {
"userBarcode": "6366520002522045",
"itemBarcode": "32356000869907",
"servicePointId": "83d474aa-ee99-4924-8704-a03e3c56e0d9",
}
loan = folio_client.check_out_by_barcode(
bc["itemBarcode"],
bc["userBarcode"],
datetime.datetime.now(),
bc["servicePointId"],
)
if loan:
folio_client.extend_open_loan(
loan[1], datetime.datetime.now(), datetime.datetime.now()
)"""
if __name__ == "__main__":
main()