How can I mock downloading file using request-mock

Viewed 17

Good day, I need to test this function using request_mock:

def loader(link, output='os.getcwd'):
    # Function loading a page from the link
    response = requests.get(link)
    data = response.text
    file_name = modify_file_name(link)
    if output == 'os.getcwd':
        directory = os.getcwd()
    else:
        directory = output
    filepath = os.path.join(directory, file_name + '.html')
    with open(filepath, 'w') as page:
        page.write(data)
    return filepath

I didn't find a tutorial of instruction for beginners. I would be grateful for advice.

0 Answers
Related