-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #714 from neo4j-contrib/fix/node-class-registry
Move Node class registry out of Database init
- Loading branch information
Showing
3 changed files
with
26 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,10 @@ def email_alias(self, value): | |
self.email = value | ||
|
||
|
||
class NodeWithoutProperty(StructuredNode): | ||
pass | ||
|
||
|
||
def test_issue_233(): | ||
class BaseIssue233(StructuredNode): | ||
__abstract_node__ = True | ||
|
@@ -101,6 +105,12 @@ def test_save_to_model(): | |
assert u.age == 3 | ||
|
||
|
||
def test_save_node_without_properties(): | ||
n = NodeWithoutProperty() | ||
assert n.save() | ||
assert n.element_id != "" | ||
|
||
|
||
def test_unique(): | ||
install_labels(User) | ||
User(email="[email protected]", age=3).save() | ||
|
@@ -231,6 +241,7 @@ def credit_account(self, amount): | |
assert len(jim.labels()) == 1 | ||
assert jim.labels()[0] == "Shopper" | ||
|
||
|
||
def test_inherited_optional_labels(): | ||
class BaseOptional(StructuredNode): | ||
__optional_labels__ = ["Alive"] | ||
|
@@ -244,16 +255,17 @@ def credit_account(self, amount): | |
self.balance = self.balance + int(amount) | ||
self.save() | ||
|
||
henry = ExtendedOptional(name='henry', balance=300).save() | ||
henry = ExtendedOptional(name="henry", balance=300).save() | ||
henry.credit_account(50) | ||
|
||
assert ExtendedOptional.__label__ == 'ExtendedOptional' | ||
assert ExtendedOptional.__label__ == "ExtendedOptional" | ||
assert henry.balance == 350 | ||
assert len(henry.inherited_labels()) == 2 | ||
assert len(henry.labels()) == 2 | ||
|
||
assert set(henry.inherited_optional_labels()) == {"Alive", "RewardsMember"} | ||
|
||
|
||
def test_mixins(): | ||
class UserMixin: | ||
name = StringProperty(unique_index=True) | ||
|