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 #37 from Sage-Bionetworks/add-activities-post
Add activities post
- Loading branch information
Showing
10 changed files
with
123 additions
and
148 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .models.activity import GraphActivity | ||
from .models.agent import GraphAgent | ||
from .models.reference import GraphReference | ||
from .models.reference import GraphReference | ||
from .builder import ActivityBuilder |
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 |
---|---|---|
|
@@ -105,4 +105,4 @@ def save(self): | |
rel.create() | ||
self.gdb.create_relationship(rel) | ||
|
||
return True | ||
return self._find_activity() |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,47 @@ | ||
import logging | ||
import pytest | ||
|
||
from synprov.models import ActivityForm | ||
from synprov.graph.controllers import activities_controller | ||
|
||
|
||
logging.basicConfig(level=logging.DEBUG) | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class TestActivitiesController: | ||
|
||
def test_create_activity_exists(self, | ||
mock_graph_data, | ||
mock_activity_request): | ||
node_count = len(mock_graph_data.nodes) | ||
rel_count = len(mock_graph_data.relationships) | ||
body = ActivityForm.from_dict(mock_activity_request) | ||
act_node = activities_controller.create_activity(body) | ||
assert len(mock_graph_data.nodes) == node_count | ||
assert len(mock_graph_data.relationships) == rel_count | ||
assert all([key in act_node for key in ['id', 'labels', 'properties']]) | ||
|
||
def test_create_activity_new(self, | ||
mock_graph, | ||
mock_activity_request): | ||
node_count = len(mock_graph.nodes) | ||
rel_count = len(mock_graph.relationships) | ||
body = ActivityForm.from_dict(mock_activity_request) | ||
act_node = activities_controller.create_activity(body) | ||
|
||
new_nodes = sum([ | ||
len(mock_activity_request['used']), | ||
len(mock_activity_request['generated']), | ||
len(mock_activity_request['agents']), | ||
1 | ||
]) | ||
new_rels = sum([ | ||
len(mock_activity_request['used']), | ||
len(mock_activity_request['generated']), | ||
len(mock_activity_request['agents']) * 2, | ||
]) | ||
|
||
assert len(mock_graph.nodes) == (node_count + new_nodes) | ||
assert len(mock_graph.relationships) == (rel_count + new_rels) | ||
assert all([key in act_node for key in ['id', 'labels', 'properties']]) |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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