Dev Notes¶
Running Tests with Python for community_scripts tests¶
There are build/tests everywhere in TRMM, that make sure things haven't gone wrong (like in the community-script
any file in the scripts
folder must have a matching entry in .json file. And every field in the .json file should be in the right format, and no duplicates...and .json needs to be properly formatted and...and...and) so there's tests.
Here's how you run tests locally (make sure python is installed first)
Running tests from VS Code
Open TERMINAL -> SSH
Setup python environment
python3 -m venv env
source env/bin/activate
pip install --upgrade pip
pip install pytest
Run tests
pytest
- Make sure git isn't going to try and sync your python environment with the repo
__pycache__/
env/
- Open TERMINAL -> PowerShell Integrated Console (make sure you're in the right path or root of your git folder)
- Setup python env
python -m venv env
You'll see /env/ folder created in your local folder
Activate your python env
.\env\Scripts\activate
look for the (env) to appear at the front of your commandline
Upgrade pip to latest, and install pytest
python -m pip install --upgrade pip
pip install pytest
Run pytest
pytest
Good test
Bad test
When done, shut down your python environment
deactivate
- Summary
python -m venv env
.\env\Scripts\activate
python -m pip install --upgrade pip
pip install pytest
pytest
Mkdocs build¶
python -m venv env
.\env\Scripts\activate
pip install --upgrade pip
pip install --upgrade setuptools wheel
pip install -r ../tacticalrmm/api/tacticalrmm/requirements-dev.txt
mkdocs serve