Tests

This project is automatically supervised using tests developed specifically for it. If you want to check sinergym has been installed successfully, run next command:

$ pytest tests/ -vv

Anyway, every time sinergym repository is updated, the tests will run automatically in a remote container using the Dockerfile to build it. Github Action will do that job.

Note

See .github/workflows YML files and Github Actions section for more information.

These tests running under pytest framework which makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries.

Install Pytest

This project has already established this dependency if you have installed extras libreries or test librery specifically (see 4. Install the package). However, to install it independently:

$ pip install pytest

Running tests

In order to run current tests:

$ pytest tests/ -vv

This runs all tests within tests/ directory. If you want verbose use -v or -vv option. To run an unique module tests, for example:

$ pytest tests/test_common.py -vv

Create new tests

These tests have been created in sinergym/tests directory, they are organized by different modules:

  • test_common.py: Tests for sinergym/sinergym/utils/common.py. Here will be all tests that check Sinergym common utils functionalities.

  • test_reward.py: Tests for sinergym/sinergym/utils/rewards.py. Here will be all tests that check implementation(s) of reward function(s) applicable to sinergym environments.

  • test_wrapper.py: Tests for sinergym/sinergym/utils/wrappers.py. Here will be all tests that check wrappers to normalize Sinergym default environment observations.

  • test_simulator.py: Tests for sinergym/sinergym/simulators/*. Here will be all tests that check low level Sinergym simulator and communication interface.

  • test_env.py: Tests for sinergym/sinergym/envs/*. Here will be all tests that check Sinergym simulation environments based on OpenAI Gym.

  • test_controller.py: Tests for sinergym/sinergym/utils/controllers.py. Here will be all tests that check agent controller like Rule-Based-Controller for example.

  • test_stable_baselines.py: Tests for Stable Baselines 3. Here will be all tests that check Sinergym simulation environments can be used correctly with Stable Baselines 3 algorithms.

If you want to make new tests, you can append to this modules or create a new one if the conceptual context is different.

Note

For more information about Sinergym tests, visit our repository README.