pynetro
Async Python wrapper for the Netro API — HTTP-agnostic.
Installation
Quick install
git clone https://github.com/kcofoni/pynetro.git
cd pynetro
pip install -e .
Development setup
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # Linux / macOS
# .venv\Scripts\activate # Windows
- Install the package and dev dependencies:
pip install -e .
pip install -r requirements-dev.txt
- Verify basic checks:
# run unit tests
pytest tests/test_client.py -v
# lint
ruff check src/ tests/
Testing
This project provides two kinds of tests:
-
Unit tests
- Fast, offline, no network required.
- Located mainly in
tests/test_client.py. - Run locally or in CI without environment variables.
-
Integration tests
- Interact with the Netro API (or rely on prepared reference responses).
- Marked with
@pytest.mark.integrationintests/test_integration.py. - Require device serial numbers and/or reference files.
Running tests:
# run all tests
pytest tests/ -v
# unit tests only
pytest tests/test_client.py -v
# integration tests (requires env vars / references)
pytest tests/test_integration.py -m integration -v
Reference files & templates
- Sensitive reference files that include real serials are NOT committed.
- Committed templates live under
tests/reference_data/*_template.json. - The test helpers in
tests/conftest.pyexpose fixtures (e.g.need_sensor_reference,need_controller_reference,need_sensor_data_reference) that:- If a reference file already exists, use it unchanged.
- If the reference is missing but a template exists:
- If a serial env var is provided (
NETRO_SENS_SERIALorNETRO_CTRL_SERIAL), the test helper generates the reference from the template by performing an internal token substitution (no external script). Common dummy tokens such asDUMMY_SERIAL,000000000000,SENSOR_SERIALorCTRL_SERIALare replaced by the provided serial. - If the template contains no serials (pure fixtures), it will be copied to create the reference (
copy_if_template=True).
- If a serial env var is provided (
- If neither reference nor template is available (or a required env var is unset), the fixture calls
pytest.skip()so the integration test is skipped cleanly.
Note:
generate_reference.pyis no longer used and has been removed — the generation is handled internally bytests/conftest.py.
Environment variables used by fixtures:
NETRO_SENS_SERIAL— sensor serial used to generate sensor referenceNETRO_CTRL_SERIAL— controller serial used to generate controller reference
Fixtures used in tests (examples):
need_sensor_reference— ensuressensor_response.jsonneed_controller_reference— ensuressprite_response.jsonneed_sensor_data_reference— ensuressensor_response_data.jsonneed_schedules_reference,need_moistures_reference,need_events_reference— ensure other refs (copy from templates if necessary)
.env.example and local .env
A .env.example file (if present) documents the environment variables the tests may require. To provide values locally, copy it to .env and edit the values:
cp .env.example .env
# then open .env and fill NETRO_SENS_SERIAL / NETRO_CTRL_SERIAL etc.
Notes:
tests/conftest.pyattempts to load a.envfile automatically (usingpython-dotenvif installed, otherwise a fallback). This allows running integration tests without exporting variables manually.- Do NOT commit your
.envcontaining real serials or secrets..envis ignored by the repo (.gitignore) by default. - In CI, either install
python-dotenvor provide the required variables as repository Actions secrets / environment variables.
Security & gitignore
- By default all
.jsonfiles are ignored and only*_template.jsonare tracked. Keep real reference files out of the repository. - If a sensitive
.jsonis already tracked, remove it from the index without deleting local copy:
git rm --cached path/to/file.json
Troubleshooting
- ImportError in CI for
dotenv: ensurepython-dotenvis installed in the job or make import optional intests/conftest.py. - If integration tests are skipped, confirm
NETRO_SENS_SERIALandNETRO_CTRL_SERIALare set or that reference templates exist.
Contributing
- Add templates (
*_template.json) for any reference data you add. - Do not commit files containing real serials or private tokens.
For more details about tests and reference management see tests/conftest.py and the test files under tests/.
Metadata
Release files for pynetro 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pynetro-0.1.5.tar.gz | 22.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pynetro-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.7 kB
Release files / pynetro-0.1.5.tar.gz
| Download URL | pynetro-0.1.5.tar.gz |
|---|---|
| Size | 22.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9d8c980be3f3140a99d578eb5dd9c05da9ba7dc9cda4ee63eb0f2e11b1f006c
|
|
BLAKE2b-256 checksum How to use checksums |
30622b9df2da4d2426352d9a45cf249db1688849f006e17e723dfbbc897c2723
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.2
|
Release files / pynetro-0.1.5-py3-none-any.whl
| Download URL | pynetro-0.1.5-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
63239f5b829736105d174d3b3ca899e1ce014f199dc9b35f13ca193e6974d5c7
|
|
BLAKE2b-256 checksum How to use checksums |
0887cadb6e6b930bdda872fecb1c93b20f9134fa1c525f45154993ca5cb468ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.2
|