-
Notifications
You must be signed in to change notification settings - Fork 11
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 #104 from nodestream-proj/fix/prevent-invalid-rela…
…tionsip-creation Prevent invalid related nodes from being passed to the Database
- Loading branch information
Showing
4 changed files
with
85 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import pytest | ||
|
||
from nodestream.model import DesiredIngestion, MatchStrategy, Node, Relationship | ||
|
||
|
||
@pytest.fixture | ||
def desired_ingestion(): | ||
return DesiredIngestion() | ||
|
||
|
||
@pytest.fixture | ||
def valid_node(): | ||
return Node("Foo", {"bar": "baz"}) | ||
|
||
|
||
@pytest.fixture | ||
def invalid_node(): | ||
return Node() | ||
|
||
|
||
@pytest.fixture | ||
def valid_relationship(): | ||
return Relationship("IS_RELATED_TO") | ||
|
||
|
||
def test_add_relationship_valid_node(desired_ingestion, valid_node, valid_relationship): | ||
desired_ingestion.add_relationship( | ||
related_node=valid_node, | ||
relationship=valid_relationship, | ||
outbound=True, | ||
match_strategy=MatchStrategy.EAGER, | ||
) | ||
assert len(desired_ingestion.relationships) == 1 | ||
|
||
|
||
def test_add_relationship_invalid_node( | ||
desired_ingestion, invalid_node, valid_relationship | ||
): | ||
desired_ingestion.add_relationship( | ||
related_node=invalid_node, | ||
relationship=valid_relationship, | ||
outbound=True, | ||
match_strategy=MatchStrategy.EAGER, | ||
) | ||
assert len(desired_ingestion.relationships) == 0 |