def test_all_predicates_have_classes(self): gc = gaffer_connector.GafferConnector( 'http://localhost:8080/rest/latest') predicates = gc.execute_get( g.GetFilterFunctions() ) predicates = json.loads(predicates) ignore_predicates = [ 'uk.gov.gchq.koryphe.predicate.AdaptedPredicate', 'uk.gov.gchq.koryphe.predicate.AdaptedPredicate', 'uk.gov.gchq.koryphe.predicate.PredicateComposite', 'uk.gov.gchq.gaffer.rest.example.ExampleFilterFunction', 'uk.gov.gchq.koryphe.tuple.predicate.TupleAdaptedPredicate', 'uk.gov.gchq.gaffer.data.element.function.ElementFilter', 'uk.gov.gchq.koryphe.tuple.predicate.TupleAdaptedPredicateComposite', 'uk.gov.gchq.gaffer.store.util.AggregatorUtil$IsElementAggregated', 'uk.gov.gchq.gaffer.graph.hook.migrate.predicate.TransformAndFilter' ] for i in ignore_predicates: if i in predicates: predicates.remove(i) for op in predicates: self.assertTrue(op in g.JsonConverter.GENERIC_JSON_CONVERTERS, 'Missing predicate class: ' + op)
def test_all_functions_have_classes(self): gc = gaffer_connector.GafferConnector( 'http://localhost:8080/rest/latest') functions = gc.execute_get( g.GetTransformFunctions() ) functions = json.loads(functions) ignore_functions = [ 'uk.gov.gchq.gaffer.operation.data.generator.EdgeIdExtractor', 'uk.gov.gchq.gaffer.store.util.AggregatorUtil$ToIngestElementKey', 'uk.gov.gchq.gaffer.rest.example.ExampleDomainObjectGenerator', 'uk.gov.gchq.gaffer.data.element.function.ElementTransformer', 'uk.gov.gchq.gaffer.traffic.generator.RoadTrafficCsvElementGenerator', 'uk.gov.gchq.koryphe.tuple.function.TupleAdaptedFunctionComposite', 'uk.gov.gchq.gaffer.store.util.AggregatorUtil$ToElementKey', 'uk.gov.gchq.koryphe.tuple.function.TupleAdaptedFunction', 'uk.gov.gchq.koryphe.function.FunctionComposite', 'uk.gov.gchq.gaffer.rest.example.ExampleTransformFunction', 'uk.gov.gchq.gaffer.data.graph.function.walk.ExtractWalkEdgesFromHop', 'uk.gov.gchq.gaffer.traffic.transform.DescriptionTransform', 'uk.gov.gchq.gaffer.store.util.AggregatorUtil$ToQueryElementKey', 'uk.gov.gchq.koryphe.tuple.TupleInputAdapter', 'uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor', 'uk.gov.gchq.gaffer.traffic.generator.RoadTrafficStringElementGenerator', 'uk.gov.gchq.gaffer.rest.example.ExampleElementGenerator', ] for i in ignore_functions: if i in functions: functions.remove(i) for op in functions: self.assertTrue(op in g.JsonConverter.GENERIC_JSON_CONVERTERS, 'Missing transform function class: ' + op)
def test_all_operations_have_classes(self): gc = gaffer_connector.GafferConnector( 'http://localhost:8080/rest/latest') operations = gc.execute_get(g.GetOperations()) operations = json.loads(operations) for op in operations: self.assertTrue(op in g.JsonConverter.GENERIC_JSON_CONVERTERS, 'Missing operation class: ' + op)
def test_class_initilisation(self): """Test that the gaffer_connector class is correctly initialised with instance attributes""" host = 'http://localhost:8080/rest/latest', verbose = False, headers = {"dummy_Header": "value"} gc = gaffer_connector.GafferConnector(host, verbose, headers) actuals = [gc._host, gc._verbose, gc._headers] expecteds = [host, verbose, headers] for actual, expected in zip(actuals, expecteds): self.assertEqual(actual, expected)
def test_execute_operation(self): gc = gaffer_connector.GafferConnector( 'http://localhost:8080/rest/latest') elements = gc.execute_operation( g.GetElements( input=[g.EntitySeed('M5:10')], view=g.View( edges=[g.ElementDefinition(group='JunctionLocatedAt')]))) self.assertEqual([ g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {}, "SOURCE") ], elements)
def test_dummy_header(self): """Test that the addition of a dummy header does not effect the standard test""" gc = gaffer_connector.GafferConnector( 'http://localhost:8080/rest/latest', headers={"dummy_Header": "value"}) elements = gc.execute_operation( g.GetElements( input=[g.EntitySeed('M5:10')], view=g.View( edges=[g.ElementDefinition(group='JunctionLocatedAt')]))) self.assertEqual([ g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {}, "SOURCE") ], elements)
def create_connector(host, verbose=False): return gaffer_connector.GafferConnector(host, verbose)
def test_is_operation_supported(self): gc = gaffer_connector.GafferConnector( 'http://localhost:8080/rest/latest') response_text = gc.is_operation_supported( g.IsOperationSupported( operation='uk.gov.gchq.gaffer.operation.impl.get.GetAllElements' )) expected_response_text = ''' { "name": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", "summary": "Gets all elements compatible with a provided View", "fields": [ { "name": "view", "className": "uk.gov.gchq.gaffer.data.elementdefinition.view.View", "required": false }, { "name": "options", "className": "java.util.Map<java.lang.String,java.lang.String>", "required": false }, { "name": "directedType", "summary": "Is the Edge directed?", "className": "java.lang.String", "options": [ "DIRECTED", "UNDIRECTED", "EITHER" ], "required": false }, { "name": "views", "className": "java.util.List<uk.gov.gchq.gaffer.data.elementdefinition.view.View>", "required": false } ], "next": [ "uk.gov.gchq.gaffer.operation.impl.add.AddElements", "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet", "uk.gov.gchq.gaffer.operation.impl.output.ToArray", "uk.gov.gchq.gaffer.operation.impl.output.ToEntitySeeds", "uk.gov.gchq.gaffer.operation.impl.output.ToList", "uk.gov.gchq.gaffer.operation.impl.output.ToMap", "uk.gov.gchq.gaffer.operation.impl.output.ToCsv", "uk.gov.gchq.gaffer.operation.impl.output.ToSet", "uk.gov.gchq.gaffer.operation.impl.output.ToStream", "uk.gov.gchq.gaffer.operation.impl.output.ToVertices", "uk.gov.gchq.gaffer.named.operation.NamedOperation", "uk.gov.gchq.gaffer.operation.impl.compare.Max", "uk.gov.gchq.gaffer.operation.impl.compare.Min", "uk.gov.gchq.gaffer.operation.impl.compare.Sort", "uk.gov.gchq.gaffer.operation.impl.GetWalks", "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements", "uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects", "uk.gov.gchq.gaffer.operation.impl.Validate", "uk.gov.gchq.gaffer.operation.impl.Count", "uk.gov.gchq.gaffer.operation.impl.CountGroups", "uk.gov.gchq.gaffer.operation.impl.Limit", "uk.gov.gchq.gaffer.operation.impl.DiscardOutput", "uk.gov.gchq.gaffer.operation.impl.Map", "uk.gov.gchq.gaffer.operation.impl.If", "uk.gov.gchq.gaffer.operation.impl.While", "uk.gov.gchq.gaffer.operation.impl.ForEach", "uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList", "uk.gov.gchq.gaffer.operation.impl.Reduce", "uk.gov.gchq.gaffer.operation.impl.join.Join", "uk.gov.gchq.gaffer.operation.impl.SetVariable", "uk.gov.gchq.gaffer.operation.impl.function.Filter", "uk.gov.gchq.gaffer.operation.impl.function.Transform", "uk.gov.gchq.gaffer.operation.impl.function.Aggregate", "uk.gov.gchq.gaffer.mapstore.operation.CountAllElementsDefaultView", "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph", "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph", "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache" ], "exampleJson": { "class": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" }, "outputClassName": "uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable<uk.gov.gchq.gaffer.data.element.Element>" } ''' self.assertEqual(json.loads(expected_response_text), json.loads(response_text))
def test_execute_get(self): self.maxDiff = None gc = gaffer_connector.GafferConnector( 'http://localhost:8080/rest/latest') response_text = gc.execute_get(g.GetOperations()) expected_response_text = ''' [ "uk.gov.gchq.gaffer.operation.impl.add.AddElements", "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet", "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", "uk.gov.gchq.gaffer.operation.impl.export.GetExports", "uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails", "uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails", "uk.gov.gchq.gaffer.operation.impl.job.GetJobResults", "uk.gov.gchq.gaffer.operation.impl.output.ToArray", "uk.gov.gchq.gaffer.operation.impl.output.ToEntitySeeds", "uk.gov.gchq.gaffer.operation.impl.output.ToList", "uk.gov.gchq.gaffer.operation.impl.output.ToMap", "uk.gov.gchq.gaffer.operation.impl.output.ToCsv", "uk.gov.gchq.gaffer.operation.impl.output.ToSet", "uk.gov.gchq.gaffer.operation.impl.output.ToStream", "uk.gov.gchq.gaffer.operation.impl.output.ToVertices", "uk.gov.gchq.gaffer.named.operation.NamedOperation", "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", "uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations", "uk.gov.gchq.gaffer.named.operation.DeleteNamedOperation", "uk.gov.gchq.gaffer.named.view.AddNamedView", "uk.gov.gchq.gaffer.named.view.GetAllNamedViews", "uk.gov.gchq.gaffer.named.view.DeleteNamedView", "uk.gov.gchq.gaffer.operation.impl.compare.Max", "uk.gov.gchq.gaffer.operation.impl.compare.Min", "uk.gov.gchq.gaffer.operation.impl.compare.Sort", "uk.gov.gchq.gaffer.operation.OperationChain", "uk.gov.gchq.gaffer.operation.OperationChainDAO", "uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain", "uk.gov.gchq.gaffer.operation.impl.GetWalks", "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements", "uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects", "uk.gov.gchq.gaffer.operation.impl.Validate", "uk.gov.gchq.gaffer.operation.impl.Count", "uk.gov.gchq.gaffer.operation.impl.CountGroups", "uk.gov.gchq.gaffer.operation.impl.Limit", "uk.gov.gchq.gaffer.operation.impl.DiscardOutput", "uk.gov.gchq.gaffer.store.operation.GetSchema", "uk.gov.gchq.gaffer.operation.impl.Map", "uk.gov.gchq.gaffer.operation.impl.If", "uk.gov.gchq.gaffer.operation.impl.While", "uk.gov.gchq.gaffer.operation.impl.ForEach", "uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList", "uk.gov.gchq.gaffer.operation.impl.Reduce", "uk.gov.gchq.gaffer.operation.impl.join.Join", "uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob", "uk.gov.gchq.gaffer.operation.impl.SetVariable", "uk.gov.gchq.gaffer.operation.impl.GetVariable", "uk.gov.gchq.gaffer.operation.impl.GetVariables", "uk.gov.gchq.gaffer.operation.impl.function.Filter", "uk.gov.gchq.gaffer.operation.impl.function.Transform", "uk.gov.gchq.gaffer.operation.impl.function.Aggregate", "uk.gov.gchq.gaffer.store.operation.GetTraits", "uk.gov.gchq.gaffer.mapstore.operation.CountAllElementsDefaultView", "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph", "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph", "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache", "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport" ] ''' self.assertEqual(json.loads(expected_response_text), json.loads(response_text))