def make_export(objects, exportable_objects=None, ie_job=None, ca_cache=None): """Make export""" query_helper = builder.QueryHelper(objects) ids_by_type = query_helper.get_ids() converter = base.ExportConverter(ids_by_type=ids_by_type, exportable_queries=exportable_objects, ie_job=ie_job, ca_cache=ca_cache) csv_data = converter.export_csv_data() object_names = "_".join(converter.get_object_names()) return csv_data, object_names
def test_expression_keys(self): """ test expression keys function Make sure it works with: empty query simple query complex query invalid complex query """ # pylint: disable=protected-access # needed for testing protected function inside the query helper query = mock.MagicMock() helper = builder.QueryHelper(query) expressions = [ (set(), {}), (set(["key_1"]), { "left": "key_1", "op": {"name": "="}, "right": "", }), (set(["key_1", "key_2"]), { "left": { "left": "key_2", "op": {"name": "="}, "right": "", }, "op": {"name": "AND"}, "right": { "left": "key_1", "op": {"name": "!="}, "right": "", }, }), (set(), { "left": { "left": "5", "op": {"name": "="}, "right": "", }, "op": {"name": "="}, "right": { "left": "key_1", "op": {"name": "!="}, "right": "", }, }), ] for expected_result, expression in expressions: self.assertEqual(expected_result, helper._expression_keys(expression))