def test_json_iterator(self): data_map = self.config.items("input_data:map") iterator = JSONIterator(data_map=data_map) path = self.config.get("input_data", "path") iterator.load_objects(path=path, root_container="JSONDataResult") for apt_dict in iterator: for attr_name, alias in data_map: self.assertIn(attr_name, apt_dict)
def test_data_filter(self): data_map = self.config.items("input_data:map") iterator = JSONIterator(data_map=data_map, filters=[data_filter]) path = self.config.get("input_data", "path") iterator.load_objects(path=path, root_container="JSONDataResult") for apt_dict in iterator: for attr_name, value in apt_dict.items(): if value: type_to_check = getattr(__builtin__, ATTR_TYPES[attr_name][1]) self.assertEqual(type(value), type_to_check)