def query(self, query, infer=True): if query == 'match $x id V123; get;': return [ MockConceptMap({ 'x': MockThing('V123', MockType('V4123', 'person', 'ENTITY')) }) ] elif query == 'match $x id V123, has name $n; get;': return [ MockConceptMap({ 'x': MockThing('V123', MockType('V4123', 'person', 'ENTITY')), 'n': MockAttribute( 'V987', 'Bob', MockAttributeType('V555', 'name', 'ATTRIBUTE', 'STRING')) }) ] elif query == 'match $x id V123; $r(child: $x, parent: $y); get;': return [ MockConceptMap({ 'x': MockThing('V123', MockType('V4123', 'person', 'ENTITY')), 'y': MockThing('V123', MockType('V4123', 'person', 'ENTITY')), 'r': MockThing('V567', MockType('V9876', 'parentship', 'RELATION')) }) ] else: raise NotImplementedError
def test_concept_dicts_are_built_as_expected_with_2_concepts(self): concept_map = MockConceptMap({ 'x': MockThing('V123', MockType('V456', 'person', 'ENTITY')), 'y': MockThing('V789', MockType('V765', 'employment', 'RELATION')), }) concept_dicts = concept_dict_from_concept_map(concept_map) expected_concept_dict = { 'x': Thing('V123', 'person', 'entity'), 'y': Thing('V789', 'employment', 'relation'), } self.assertEqual(expected_concept_dict, concept_dicts)
def test_concept_dicts_are_built_as_expected(self): concept_map = MockConceptMap({'x': MockThing('V123', MockType('V456', 'person', 'ENTITY'))}) concept_dicts = concept_dict_from_concept_map(concept_map) expected_concept_dicts = {'x': Thing('V123', 'person', 'entity')} self.assertEqual(expected_concept_dicts, concept_dicts)
def query(self, query, infer=True): if query == 'match $x id V123; get;': return [ MockConceptMap({ 'x': MockThing('V123', MockType('V4123', 'person', 'ENTITY')) }) ] elif query == 'match $y id V123; get;': return []