Unit Testing: Mock list_users method in Python

Dominic-S
Dominic-S Registered Posts: 17

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

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,160 Neuron

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

  • Dominic-S
    Dominic-S Registered Posts: 17

    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

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,160 Neuron

    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.

  • Dominic-S
    Dominic-S Registered Posts: 17

    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.

Setup Info
    Tags
      Help me…