Unit Testing: Mock list_users method in Python

Dominic-S
Level 3
Unit Testing: Mock list_users method in Python

Hi,

 Would someone suggest a way to mock dataiku.api_client().list_users(). I tried several different ways and none seems to be working.

  Thanks

0 Kudos
4 Replies
Turribeach

I am not sure I understand what exactly you are trying to do, can you please clarify?

0 Kudos
Dominic-S
Level 3
Author

Hi,

  I have a method to get a list of users by calling dataiku.api_client().list_users() and process it. Now I would like to write a unit test for my processing logic, but does not require to test Dataiku's list_users method. What will be the best way to mock the list_users() method and in general any Dataiku's APIs?

  Thanks

0 Kudos

Personally I think you should not spend time on this. The Dataiku APIs are well understood, very solid and do not change that often. Specially with the list_users() API being read only and pretty simple. We have written a large amount of code using the Dataiku API and we barely see any issues, most of which are documented in the release notes. If you still want to test your API code I would suggest to write a regression pack which uses all the APIs you want to test and has expected inputs and outputs. Then run it against a live DSS instance running the version you want to test against. 

0 Kudos
Dominic-S
Level 3
Author

That is exactly why I am trying to mock list_users. I am not writing unit test to test Dataiku's APIs, hence using mock to return expected values.

0 Kudos