0

Could someone please let me know how to mock the DatabaseAPI object for below unit test case example. Getting error at getURL in test_load.py file.

File load.py

from database_api import DatabaseAPI

Database_api_client = DatabaseAPI(username, password)

def loadFile():
   #some code to load the file

File database_api.py

class DatabaseAPI:
   def __init__(self, username, password):
     self.getUrl()

   def getUrl(self):
     requests.options(url=SomeURL, headers=request_header)

File test_load.py

import unittest
from load import loadFile


class TestLoad(unittest.TestCase):
    def test_loadFile(self):
     #some code to test loadfile
     But getting get_url connection error. I need to mock the "Database_api_client = DatabaseAPI(username, password)" object
 But getting get_url connection error. I need to mock the "Database_api_client = DatabaseAPI(username, password)" object
Veds
  • 11
  • 1
  • 6
  • I don't see anything in your code setting up a mock. Maybe start with the examples in a guide like this? https://realpython.com/python-mock-library/ – Tristan May 17 '23 at 17:55

0 Answers0