def test_keys_of_dicts_empty(self): """ Testing keys_of_dicts to verify that keys are extracted from an empty a list of dictionaries """ self.element = etl.Element(self.file_name_csv_empty) self.element.read_csv() given_list_of_keys = list(self.element.keys_of_dicts()) self.assertEqual(given_list_of_keys, list())
def test_read_xml_empty(self): """ Testing read_xml using an empty XML file to make sure it is being processed correctly """ self.element = etl.Element(self.file_name_xml_empty) self.element.read_xml() given_list = self.element.list_of_dicts self.assertEqual(given_list, list())
def test_keys_of_dicts(self): """ Testing keys_of_dicts to verify that keys are extracted from a list of dictionaries """ self.element = etl.Element(self.file_name_csv) self.element.read_csv() given_list_of_keys = list(self.element.keys_of_dicts()) expected_list_of_keys = ['D1', 'D2', 'M1', 'M2'] self.assertEqual(given_list_of_keys, expected_list_of_keys)
def test_read_xml(self): """ Testing read_xml using a XML file to make sure it is being processed correctly """ self.element = etl.Element(self.file_name_xml) self.element.read_xml() given_list = self.element.list_of_dicts expected_list = [{'D1': 'a', 'D2': 'a', 'M1': '0', 'M2': '0'}, {'D1': 'b', 'D2': 'b', 'M1': '2', 'M2': '2'}] self.assertEqual(given_list, expected_list)
def test_read_json(self): """ Testing read_json using a JSON file to make sure it is being processed correctly """ self.element = etl.Element(self.file_name_json) self.element.read_json() given_list = self.element.list_of_dicts expected_list = [{'D1': 'a', 'D2': 'a', 'M1': 0, 'M2': 0}, {'D1': 'b', 'D2': 'b', 'M1': 1, 'M2': 1}] self.assertEqual(given_list, expected_list)
def test_read_csv(self): """ Testing read_csv using a CSV file to make sure it is being processed correctly """ self.element = etl.Element(self.file_name_csv) self.element.read_csv() given_list = self.element.list_of_dicts expected_list = [collections.OrderedDict([('D1', 'a'), ('D2', 'b'), ('M1', '1'), ('M2', '1')]), collections.OrderedDict([('D1', 'b'), ('D2', 'a'), ('M1', '0'), ('M2', '0')])] self.assertEqual(given_list, expected_list)