Skip to content

Commit

Permalink
Merge pull request mogui#187 from kensho/add_abstract_field
Browse files Browse the repository at this point in the history
Add abstract field to class objects
  • Loading branch information
TropicalPenguin committed May 23, 2016
2 parents 407cb66 + 05db664 commit 90fa9f0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyorient/ogm/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def extract_properties(property_schema, is_edge):
props.update(extract_properties(class_def['properties'], is_edge))

props['class_fields'] = class_def.get('customFields', None) or {}
props['abstract'] = class_def.get('abstract', False)

if bases:
# Create class for the graph type
Expand Down
20 changes: 20 additions & 0 deletions tests/test_ogm.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,3 +789,23 @@ def testCustomFields(self):
self.assertEquals(
{'test_field_1': 'test string two'},
g.registry['classfieldedge'].class_fields)


class OGMTestAbstractField(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(OGMTestAbstractField, self).__init__(*args, **kwargs)
self.g = None

def setUp(self):
g = self.g = Graph(Config.from_url('abstract_classes', 'root', 'root'
, initial_drop=True))
g.client.command('CREATE CLASS AbstractClass EXTENDS V ABSTRACT')
g.client.command('CREATE CLASS ConcreteClass EXTENDS V')

def testAbstractFlag(self):
g = self.g

database_registry = g.build_mapping(
declarative_node(), declarative_relationship(), auto_plural=True)
self.assertTrue(database_registry['AbstractClass'].abstract)
self.assertFalse(database_registry['ConcreteClass'].abstract)

0 comments on commit 90fa9f0

Please sign in to comment.