diff --git a/testsuite/pytests/sli2py_regressions/test_ticket_737.py b/testsuite/pytests/sli2py_regressions/test_ticket_737.py new file mode 100644 index 0000000000..39ba304cee --- /dev/null +++ b/testsuite/pytests/sli2py_regressions/test_ticket_737.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# +# test_ticket_737.py +# +# This file is part of NEST. +# +# Copyright (C) 2004 The NEST Initiative +# +# NEST is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# NEST is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with NEST. If not, see . + +import nest +import pytest + +SKIP_LIST = ["step_rate_generator"] + +# Get all stimulator models +stimulators = [ + m for m in nest.node_models if m not in SKIP_LIST and nest.GetDefaults(m).get("element_type") == "stimulator" +] + + +@pytest.mark.parametrize("stim_model", stimulators) +def test_multiple_static_synapse_connections(stim_model): + """ + Regression test for Ticket #737. + + Ensure that stimulation devices can only be connected with a single synapse type. + """ + # First test: multiple connections with same type (static_synapse) + nest.ResetKernel() + stim = nest.Create(stim_model) + n = nest.Create("iaf_psc_alpha") + nest.Connect(stim, n, "all_to_all", syn_spec="static_synapse") + nest.Connect(stim, n, "all_to_all", syn_spec="static_synapse") + + # Second test: multiple connections of user-defined type + nest.ResetKernel() + stim = nest.Create(stim_model) + n = nest.Create("iaf_psc_alpha") + synmodel = f"{stim_model}_syn" + nest.CopyModel("static_synapse", synmodel) + nest.Connect(stim, n, "all_to_all", syn_spec=synmodel) + nest.Connect(stim, n, "all_to_all", syn_spec=synmodel) + + # Third test: no multiple connections with different types + nest.ResetKernel() + stim = nest.Create(stim_model) + n = nest.Create("iaf_psc_alpha") + synmodel = f"{stim_model}_syn" + nest.CopyModel("static_synapse", synmodel) + nest.Connect(stim, n, "all_to_all", syn_spec="static_synapse") + with pytest.raises(nest.NESTError): + nest.Connect(stim, n, "all_to_all", syn_spec=synmodel) diff --git a/testsuite/regressiontests/ticket-737.sli b/testsuite/regressiontests/ticket-737.sli deleted file mode 100644 index 778ee86cde..0000000000 --- a/testsuite/regressiontests/ticket-737.sli +++ /dev/null @@ -1,99 +0,0 @@ -/* - * ticket-737.sli - * - * This file is part of NEST. - * - * Copyright (C) 2004 The NEST Initiative - * - * NEST is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * NEST is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with NEST. If not, see . - * - */ - -/** @BeginDocumentation - -Name: testsuite::ticket-737 Ensure that stimulation devices can only be connected with a single synapse type - -Synopsis: (ticket-737) run -> NEST exits if test fails - -Description: -Ensure that NEST throws an exception if one tries to connect poisson_generator -(sending DSSpikeEvents), noise_generator (sending DSCurrentEvents) or multimeter -(sending DataLoggingRequest) to a neuron using a plastic synapse. - -spike_generator slips through this test, since it usually sends SpikeEvent. But it -is no danger if it sends DSSpikeEvents for weighted spikes, since it sends precisely -one DSSpikeEvent per spike. - -Author: Hans Ekkehard Plesser, 2014-11-06 - */ - -(unittest) run -/unittest using - -M_ERROR setverbosity - -% The following models will not be tested: -/skip_list [ - /step_rate_generator %connected with rate_connection_delayed -] def - -/stimulators GetKernelStatus /node_models get -{ - GetDefaults /element_type get /stimulator eq -} Select def - -/stimulators stimulators { skip_list exch MemberQ not } Select def - -% first test: multiple connections with same type -{ - stimulators - { - ResetKernel - Create /stim Set - /iaf_psc_alpha Create /n Set - stim n /all_to_all /static_synapse Connect - stim n /all_to_all /static_synapse Connect - } forall -} pass_or_die - -% second test: multiple connections of user-defined type -{ - stimulators - { - ResetKernel - /stimname Set - stimname Create /stim Set - /iaf_psc_alpha Create /n Set - /synmodel stimname cvs (_syn) join cvlit def - /static_synapse synmodel CopyModel - stim n /all_to_all synmodel Connect - stim n /all_to_all synmodel Connect - } forall -} pass_or_die - -% third test: no multiple connections with different types -% test must fail if a single case fails -stimulators -{ - ResetKernel - /stimname Set - stimname Create /stim Set - /iaf_psc_alpha Create /n Set - /synmodel stimname cvs (_syn) join cvlit def - /static_synapse synmodel CopyModel - stim n /all_to_all /static_synapse Connect - { stim n /all_to_all synmodel Connect } fail_or_die -} forall - -endusing