Test Particles
Unit-test the function
Section titled “Unit-test the function”Save the function from your first Particle as tools.py, then run this alongside it:
from tools import priority
assert abs(priority(0.9, 0.8) - 0.72) < 1e-10assert priority(0.0, 1.0) == 0.0Test the SQL call
Section titled “Test the SQL call”Load the module in a disposable server, then run:
SELECT priority(0.9, 0.8) AS score;SELECT priority(NULL, 0.8) AS missing_score;Check that the first result is approximately 0.72 and the second is NULL.
Test application behavior
Section titled “Test application behavior”Include boundary values, invalid types, dependency failures and realistic input sizes. Check the client’s error handling as well as successful output.
Test a restart
Section titled “Test a restart”Restart with the same configuration and data directory. Call the function again. This confirms that your selected loading or deployment method matches how the application will run.