Testing of Recommender Service

As of Totara 17 the recommender service (ml_recommender) is now deprecated. Please refer to the Machine Learning Service documentation to find out more about how Totara recommendations work.

Totara has developed the algorithms of the Recommender service in Python. Like the core Totara development, the Recommender service is integrated with a testing framework to ensure that code can be tested for the expected responses.

This page provides detail 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 Recommender 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_recommender/python/ 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 at pytest support for unittest.