testing and development workflow
There is no pytest suite. The repo’s smoke test is test_signin.py against the live StudentPortalAPI.
test_signin.py#
It does not import Webportal. It copies the two login POSTs:
- Read
UIDandPASSfrom the environment. Exit if missing. The error text says “export USERNAME and PASSWORD”, which does not match theos.getenvkeys. - Build
{username, usertype: "S", captcha: {captcha, hidden}}with a hardcoded captcha pair,serialize_payload, POST/token/pretoken-checkwithLocalName. - On Success, pop
rejectedData, setModulenameandpasswordotpvalue, encrypt, POST/token/generate-token1. pprintthe JSON.
flowchart TD Env["UID and PASS"] --> P1["POST pretoken-check"] P1 -->|not Success| Fail["exit 1"] P1 --> P2["POST generate-token1"] P2 --> Print["pprint JSON"]
export UID="enrollment"
export PASS="password"
python test_signin.py
That hits production. Treat it as a credentialed integration check, not CI.
Adding an endpoint#
flowchart LR
Spy["watch portal JS / HAR"] --> Hit["Webportal method"]
Hit --> Auth["@authenticated if needed"]
Auth --> Enc{"portal encrypts body?"}
Enc -->|yes| Ser["serialize_payload"]
Enc -->|no| Json["json=dict"]
Ser --> Underscore["self.__hit"]
Json --> Underscore
Underscore --> Model["from_json or raw dict"]Keep portal typos in request keys. Map them to underscored attributes only inside models.
Local loop#
poetry install --with docs
poetry run python -c "from pyjiit.encryption import generate_local_name; print(generate_local_name())"
poetry run sphinx-build -b html docs docs/_build/html
Debug a payload:
poetry run python -m pyjiit.encryption '<base64 ciphertext>'
That path runs deserialize_payload in encryption.py’s __main__.
What CI does not run#
documentation.yml builds Sphinx. python-publish.yml publishes. Neither runs test_signin.py. A broken login still deploys docs.
flowchart LR Push["git push"] --> Docs["sphinx-build"] Release["GitHub release"] --> PyPI["poetry publish"] Human["developer"] --> Live["test_signin.py"]