|
| 1 | +from ..utilities import load_data |
| 2 | + |
| 3 | +from textwrap import wrap |
| 4 | + |
| 5 | + |
| 6 | +def handle_lpa_get(query_params): |
| 7 | + |
| 8 | + if "lpaonlinetoolid" in query_params: |
| 9 | + lpa_online_tool_id = query_params["lpaonlinetoolid"] |
| 10 | + print(f"using lpa online tool with id {lpa_online_tool_id}") |
| 11 | + |
| 12 | + if lpa_online_tool_id[0] == "A": |
| 13 | + print(f"test_id is a valid lpa-online-tool id: {lpa_online_tool_id}") |
| 14 | + |
| 15 | + response_data = load_data( |
| 16 | + parent_folder="lpas", |
| 17 | + filename="lpa_online_tool_response.json", |
| 18 | + as_json=False, |
| 19 | + ) |
| 20 | + |
| 21 | + response_data["onlineLpaId"] = lpa_online_tool_id |
| 22 | + |
| 23 | + response_data = [response_data] |
| 24 | + |
| 25 | + return 200, response_data |
| 26 | + |
| 27 | + elif lpa_online_tool_id[:5] == "crash": |
| 28 | + print("oh no you crashed sirius") |
| 29 | + |
| 30 | + response_code = lpa_online_tool_id[-3:] |
| 31 | + |
| 32 | + return response_code, f"Sirius broke bad - error {response_code}" |
| 33 | + |
| 34 | + else: |
| 35 | + print(f"{lpa_online_tool_id} is not a lpa-online-tool id") |
| 36 | + return 404, "" |
| 37 | + |
| 38 | + elif "uid" in query_params: |
| 39 | + |
| 40 | + sirius_uid = str(query_params["uid"]) |
| 41 | + |
| 42 | + print(f"using use my lpa with id {sirius_uid}") |
| 43 | + |
| 44 | + if sirius_uid[0] == "7": |
| 45 | + print(f"test_id is a valid sirius uid: {sirius_uid}") |
| 46 | + |
| 47 | + response_data = load_data( |
| 48 | + parent_folder="lpas", filename="use_an_lpa_response.json", as_json=False |
| 49 | + ) |
| 50 | + |
| 51 | + response_data["uid"] = "-".join(wrap(sirius_uid, 4)) |
| 52 | + |
| 53 | + response_data = [response_data] |
| 54 | + |
| 55 | + return 200, response_data |
| 56 | + |
| 57 | + elif len(sirius_uid) == 3: |
| 58 | + print("oh no you crashed sirius") |
| 59 | + |
| 60 | + response_code = sirius_uid |
| 61 | + |
| 62 | + return response_code, f"Sirius broke bad - error {response_code}" |
| 63 | + |
| 64 | + else: |
| 65 | + print(f"{sirius_uid} is not a sirius uid") |
| 66 | + return 404, "" |
0 commit comments