Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-1.6.5' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
scottx611x committed Jul 18, 2018
2 parents 95e2f8a + 4d61e10 commit 26a9be9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
16 changes: 14 additions & 2 deletions refinery/tool_manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,13 @@ def launch(self):
def _visualization_saved(sender, instance, *args, **kwargs):
# Once a VisualizationTool is created with a display_name there are no
# further changes being made
if instance.display_name:
if instance.display_name and not Event.objects.filter(
data_set=instance.dataset,
user=instance.get_owner(),
details=json.dumps({'display_name': instance.display_name}),
type=Event.UPDATE,
sub_type=Event.VISUALIZATION_CREATION
).exists():
Event.record_data_set_visualization_creation(
instance.dataset, instance.display_name
)
Expand Down Expand Up @@ -1472,7 +1478,13 @@ def upload_datafile_to_library_from_url(self, library_id, datafile_url):
def _workflow_saved(sender, instance, *args, **kwargs):
# Once a WorkflowTool is created with a display_name there are no
# further changes being made
if instance.display_name:
if instance.display_name and not Event.objects.filter(
data_set=instance.dataset,
user=instance.get_owner(),
details=json.dumps({'display_name': instance.display_name}),
type=Event.UPDATE,
sub_type=Event.ANALYSIS_CREATION
).exists():
Event.record_data_set_analysis_creation(
instance.dataset, instance.display_name
)
24 changes: 24 additions & 0 deletions refinery/tool_manager/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4054,6 +4054,18 @@ def test_visualization_tool_creation_triggers_a_single_event(self):
Event.objects.get(sub_type=Event.VISUALIZATION_CREATION)
)

def test_visualization_tool_single_event_creation_after_two_saves(self):
tool = create_tool_with_necessary_models("VISUALIZATION")
tool.save()

# A Tool needs a Dataset to be created. Assert that there is one Event
# for DataSet creation and one for Tool creation
self.assertEqual(Event.objects.count(), 2)
self.assertIsNotNone(Event.objects.get(type=Event.CREATE))
self.assertIsNotNone(
Event.objects.get(sub_type=Event.VISUALIZATION_CREATION)
)

def test_workflow_tool_creation_triggers_a_single_event(self):
create_tool_with_necessary_models("WORKFLOW")

Expand All @@ -4064,3 +4076,15 @@ def test_workflow_tool_creation_triggers_a_single_event(self):
self.assertIsNotNone(
Event.objects.get(sub_type=Event.ANALYSIS_CREATION)
)

def test_workflow_tool_single_event_creation_after_two_saves(self):
tool = create_tool_with_necessary_models("WORKFLOW")
tool.save()

# A Tool needs a Dataset to be created. Assert that there is one Event
# for DataSet creation and one for Tool creation
self.assertEqual(Event.objects.count(), 2)
self.assertIsNotNone(Event.objects.get(type=Event.CREATE))
self.assertIsNotNone(
Event.objects.get(sub_type=Event.ANALYSIS_CREATION)
)

0 comments on commit 26a9be9

Please sign in to comment.