Proper way to mock classes, functions and libraries

elena florence

Proper way to mock classes, functions and libraries

I've recently started to delve into the Python test world and I can't seem to understand what to test in this specific class I've written.

import tableauserverclient

class TableauManager(object):
    def __init__(self, server, tableau_user, password):
        self.server = server
        self.tableau_user = tableau_user
        self.password = password

    def fetch_tableau_users(self, server, tableau_user, password):
        # Setup Connection String
        tableau_auth = tableauserverclient.TableauAuth(tableau_user, password, site_id='')
        server = tableauserverclient.Server(server, use_server_version=True)
        with server.auth.sign_in(tableau_auth):
            tbusers = list(tableauserverclient.Pager(server.users))
        return tbusers

Now this class connects to a service and gets a list of users from said service. What I think I have to do here is to mock tableauserverclient library and make sure I'm passing arguments when using tableauserverclient.TableauAuth but whenever I don't understand how to mock the library or if I should just mock fetch_tableau_users all together.

Thanks in advance for the help!