From 12d11604edd189e4678447d3c4487069be636eff Mon Sep 17 00:00:00 2001 From: elliot-100 <3186037+elliot-100@users.noreply.github.com> Date: Mon, 23 Feb 2026 16:48:19 +0000 Subject: [PATCH] add profile summary to `manual_test_functions.py` --- examples/manual_test_functions.py | 48 ++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/examples/manual_test_functions.py b/examples/manual_test_functions.py index b4984cb..cb2d6ae 100644 --- a/examples/manual_test_functions.py +++ b/examples/manual_test_functions.py @@ -3,7 +3,8 @@ Intended as a simple end-to-end test for assurance when making changes, where there are gaps in test suite coverage. -Doesn't yet use `get_person(user)` or any `send_`, `update_` methods.""" +Doesn't yet use `get_person(user)` or any `send_`, `update_` methods. +""" import asyncio import tempfile @@ -19,39 +20,44 @@ async def main() -> None: + + # SPOND s = spond.Spond(username=username, password=password) - # GROUPS + # Profile + print("\nGetting profile...") + profile = await s.get_profile() + print(_profile_summary(profile)) + # Groups print("\nGetting all groups...") groups = await s.get_groups() print(f"{len(groups)} groups:") for i, group in enumerate(groups): print(f"[{i}] {_group_summary(group)}") - # EVENTS - + # Events print(f"\nGetting up to {MAX_EVENTS} events...") events = await s.get_events(max_events=MAX_EVENTS) print(f"{len(events)} events:") for i, event in enumerate(events): print(f"[{i}] {_event_summary(event)}") - # CHATS (MESSAGES) - + # Chats (messages) print(f"\nGetting up to {MAX_CHATS} chats...") chats = await s.get_messages(max_chats=MAX_CHATS) print(f"{len(chats)} chats:") for i, chat in enumerate(chats): print(f"[{i}] {_chat_summary(chat)}") - # ATTENDANCE EXPORT - + # Attendance export print("\nGetting attendance report for the first event...") e = events[0] data = await s.get_event_attendance_xlsx(e["id"]) with tempfile.NamedTemporaryFile( - mode="wb", suffix=".xlsx", delete=False + mode="wb", + suffix=".xlsx", + delete=False, ) as temp_file: temp_file.write(data) print(f"Check out {temp_file.name}") @@ -61,15 +67,27 @@ async def main() -> None: # SPOND CLUB sc = club.SpondClub(username=username, password=password) print(f"\nGetting up to {MAX_TRANSACTIONS} transactions...") + + # Transactions transactions = await sc.get_transactions( - club_id=club_id, max_items=MAX_TRANSACTIONS + club_id=club_id, + max_items=MAX_TRANSACTIONS, ) print(f"{len(transactions)} transactions:") for i, t in enumerate(transactions): print(f"[{i}] {_transaction_summary(t)}") + await sc.clientsession.close() +def _profile_summary(profile: JSONDict) -> str: + return ( + f"id='{profile['id']}', " + f"firstName='{profile['firstName']}, " + f"lastName='{profile['lastName']}'" + ) + + def _group_summary(group: JSONDict) -> str: return f"id='{group['id']}', name='{group['name']}'" @@ -100,14 +118,16 @@ def _transaction_summary(transaction: JSONDict) -> str: ) -def _abbreviate(text, length) -> str: +def _abbreviate(text: str, length: int) -> str: """Abbreviate long text, normalising line endings to escape characters.""" escaped_text = repr(text) if len(text) > length: return f"{escaped_text[:length]}[…]" + return escaped_text -loop = asyncio.new_event_loop() -asyncio.set_event_loop(loop) -asyncio.run(main()) +if __name__ == "__main__": + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + asyncio.run(main())