Add test for group deletion signal
@@ -27,6 +27,21 @@ class TestExperimentGroupModel(BaseTest):
assert len(experiment_group.pending_experiments) == 1
assert len(experiment_group.running_experiments) == 1
+ def test_experiment_group_deletion_triggers_experiments_deletion(self):
+ with patch('projects.tasks.start_group_experiments.apply_async') as mock_fct:
+ experiment_group = ExperimentGroupFactory()
+
+ assert mock_fct.call_count == 1
+
+ assert Experiment.objects.filter(experiment_group=experiment_group).count() == 2
+
+ with patch('spawner.scheduler.stop_experiment') as mock_fct:
+ experiment_group.delete()
+
+ assert mock_fct.call_count == 2
+
+ assert Experiment.objects.filter(experiment_group=experiment_group).count() == 0
+
class TestProjectModel(BaseTest):
def test_has_code(self):
