Testing of Machine Learning Service
Totara has developed the algorithms of the Machine Learning Service in Python. Like the core Totara development, the Machine Learning Service is integrated with a testing framework to ensure that code can be tested for the expected responses.
This page provides details on how to set up a test environment.
Test writing framework (unittest
)
The unit test framework in Python is called unittest
, which comes packaged with Python.
Test running framework (pytest
)
There are many test running frameworks available for Python. Totara has integrated the pytest
test running framework for the Machine Learning Service. Python does not come with pytest
 preinstalled, therefore it must be installed in your development environment to run the test. This can be easily installed via the command line from PyPI using the following command:
pip install pytest
From the extensions/ml_service/
directory, execute the following command to run the tests:
python -m pytest -v
More information on the usage of pytest
 for the tests written in unittest
can be found in the pytest documentation.