I am new in mock and tests for python code(whatever code).
I'm trying to test my function main.py
def get_channel_list():
sc = SlackClient(get_token())
channels_list_json = sc.api_call("channels.list")
if channels_list_json['ok'] == True:
return channels_list_json
that is function that I'm trying to test
I need to mock patch sc.api_call("channels.list")
to return JSON object
but I can't find any examples like this that would help me to figure out how to do it.
Evrething I found was like this example Mocking a class method...
I think it would look like this:
@patch.object(SlackClient, 'api_call')
def test_get_channel_list():
assert get_channel_list() != ""
I don't have to to test lib I need to test the rest of my code in the function that I mentioned before. Thanks for any help, I'm realy stack with this test.