The function below opens and loads a Json file. My question is whats the best approach to test it?
def read_file_data(filename, path):
os.chdir(path)
with open(filename, encoding="utf8") as data_file:
json_data = json.load(data_file)
return json_data
filename and path are passed in as sys.argv's.
I figured that i would need sample data in my test case for a start but not sure how i would actually use it to test the function
class TestMyFunctions(unittest.TestCase):
def test_read_file_data(self):
sample_json = {
'name' : 'John',
'shares' : 100,
'price' : 1230.23
}
Any pointer will be appreciated.