def test_find_field_bad_input_list(self): """ Tests the case where we pass find_field a list """ parsed_res = process_json.find_field("first_name", ["Shirley", "Bob"]) self.assertEqual(None, parsed_res)
def test_find_field_bad_input_empty_string(self): """ Tests the case where we pass find_field None """ parsed_res = process_json.find_field("first_name", "") self.assertEqual(None, parsed_res)
def test_find_field_empty_dict(self): """ Tests the case where we pass find_field an empty dictionary """ parsed_res = process_json.find_field("first_name", {}) self.assertEqual(None, parsed_res)
def run_find_field_on_string(data: str): """ Runs the process_json.find_field on the supplied data string, searching specifically for a "first_name" field :param data: a JSON formatted string to be searched :return: the results of running find_field for "first_name" """ data_dict = json.loads(data) results = process_json.find_field("first_name", data_dict) return results