I am basically a pretty newbie to unit mock tests here and I am trying to perform one here and looking for guidance.
I have two class methods that gets database source names from the get_sources method and database list from the get_pds_id method. Both of these are in list formats. Then there is a logic that checks sources_db_list and db_list to check if there are any new sources and it appends to the new_sources list.
create_sources.py:
class CreateSources():
def __init__(self):
def get_sources(self):
return list_item
def get_pds_id(self):
return list_item
def get_new_sources(self):
sources_db_list = self.get_sources()
sources_db_list = list(dict.fromkeys(dbt_sources_db_list))
db_list = self.get_pds_id()
db_list = list(dict.fromkeys(dremio_db_path))
new_sources = [a for a in dbt_sources_db_list if a not in [x.lower() for x in dremio_db_path]]
return new_sources
Now I want to create a unit mock test on get_new_sources class method that outputs true or false if there are any new sources. How do I do that? I have no clue if I need to generate fake data or use the existing list outputs and perform unit mock tests.
This is what I tried and I did not know how to move forward after this
class TestDremioCreateUpdateSources(unittest.TestCase):
def testnewsource(self, mock_get_new_source):
testgetsources = DremioCreateUpdateSources().get_new_sources()
print(testgetsources)