How to test Storage.set

Hi

I have a method that save some results to storage using Storage().set(...).
How do I test that the method saves the correct results, i.e. checks the input for Storage().set?

Hello Thomas,

Welcome on the VIKTOR community forum!

In general, you can ‘mock’ objects within tests using Python’s built-in unittest.mock library. You can patch VIKTOR’s Storage.set function and call assert_called_once_with to test whether it was called with the desired input.

1 Like