precice / micro-manager

A manager tool to facilitate two-scale coupling in multi-physics simulations using preCICE.
GNU Lesser General Public License v3.0
16 stars 11 forks source link

Add unit tests for all user side functions of the Micro Manager #19

Closed IshaanDesai closed 1 year ago

IshaanDesai commented 1 year ago

All the functions in the file micro_manager/micro_manager.py needs to have unit tests for testing their behavior in several situations.

erikscheurer commented 1 year ago

Due to the nature of the micro-manager, we need a dummy class that is passed to the micro-manager that the micro-problem can extend. Otherwise we can't test the initialization and the solve function for example is also called on this micro-solver and we do not get an output of the MicroManager.solve function if we do not pass some class that implements the solve function.

The micro-manager package itself imports pyprecice, which also complicates things.

I would propose that we compile the python bindings which the micro-manager is using with a dummy interface, potentially even the interface that is already implemented in the for the python bindings and then call the functions in such a way that we know what output we would get from the python bindings dummy interface.

The other option I am thinking about are

IshaanDesai commented 1 year ago

To test the functions in MicroManager class we need to directly call them. The idea of unit tests is to really test only that function, so we should try to keep other software packages as minimal as possible. Lets do the following: mock the Python interface of preCICE and call its functions in the Micro Manager functions that we want to test. We would still do import precice, but rather than importing pyprecice, we would import the dummy version. Having a dummy micro simulation class makes sense.

In unit testing we should not actually initialize preCICE, as this will unnecessarily complicate things and go more towards an integration test.