I would like to mock a method for unit testing like this:
get_tree_test.py
from company.marketing_tree import get_tree
class MidNightTests(TestCase):
@mock.patch("company.analytics.get_fb_data", autospec=True)
def test_first_midnight(self, mock_fb_data):
mock_fb_data.return_value = {}
get_tree()
get_tree.py
from company.analytics import get_fb_data
def get_tree():
executor = ThreadPoolExecutor(max_workers=2)
data_caller = executor.submit(get_data)
info_caller = executor.submit(get_info)
def get_data():
executor = ThreadPoolExecutor(max_workers=2)
first_data = exeuctor.submit(get_fb_data)
I do see that mock_fb_data.return_value = {} is created as a mock object, but when I debug get_data() method I see that get_fb_data is a function and not a mock
What am I missing?