def test_valid_element_in_same_line(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoElementInSameLine.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_invalid_element_not_defined_in_scope(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')), 'CoCoVariableNotDefined.nestml')) self.assertEqual(len(Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 5)
def test_invalid_ode_correctly_typed(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')), 'CoCoOdeIncorrectlyTyped.nestml')) self.assertTrue(len(Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)) > 0)
def test_valid_continuous_input_ports_not_specified(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoContinuousInputPortQualifierSpecified.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_invalid_current_buffers_not_specified_with_keywords(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')), 'CoCoCurrentBufferQualifierSpecified.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 1)
def test_valid_no_nest_collision(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoNestNamespaceCollision.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_valid_order_of_equations_correct(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoNoOrderOfEquations.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_valid_numerator_of_unit_one(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoUnitNumeratorNotOne.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_valid_no_values_assigned_to_input_ports(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoValueAssignedToInputPort.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_valid_inline_expression_has_several_lhs(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoInlineExpressionWithSeveralLhs.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_valid_function_unique_and_defined(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoFunctionNotUnique.nestml')) self.assertEqual( len(Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_valid_redundant_input_port_keywords_detected(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoInputPortWithRedundantTypes.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_valid_parameters_assigned_only_in_parameters_block(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoParameterAssignedOutsideBlock.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_valid_function_with_wrong_arg_number_detected(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoFunctionCallNotConsistentWrongArgNumber.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_valid_convolve_correctly_defined(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoConvolveNotCorrectlyProvided.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_invalid_vector_parameter_declaration(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')), 'CoCoVectorParameterDeclaration.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 1)
def test_valid_incorrect_return_stmt_detected(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoIncorrectReturnStatement.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_valid_ode_vars_outside_init_block_detected(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoOdeVarNotInInitialValues.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_valid_init_values_have_rhs_and_ode(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoInitValuesWithoutOde.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.WARNING)), 2)
def test_invalid_each_block_unique(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')), 'CoCoEachBlockUnique.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 2)
def test_valid_spike_input_port_without_datatype(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoSpikeInputPortWithoutType.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_valid_expression_correctly_typed(self): Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoIllegalExpression.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_invalid_output_port_defined_if_emit_call(self): """test that an error is raised when the emit_spike() function is called by the neuron, but a spiking output port is not defined""" Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')), 'CoCoOutputPortDefinedIfEmitCall-2.nestml')) self.assertTrue(len(Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)) > 0)
def test_valid_output_port_defined_if_emit_call(self): """test that no error is raised when the output block is missing, but not emit_spike() functions are called""" Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoOutputPortDefinedIfEmitCall.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_variable_with_same_name_as_unit(self): Logger.set_logging_level(LoggingLevel.NO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoVariableWithSameNameAsUnit.nestml')) self.assertEqual( len(Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.WARNING)), 3)
def test_valid_co_co_priorities_correctly_specified(self): """ """ Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoPrioritiesCorrectlySpecified.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_synapse_list()[0], LoggingLevel.ERROR)), 0)
def test_valid_co_co_resolution_legally_used(self): """ """ Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'valid')), 'CoCoResolutionLegallyUsed.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_synapse_list()[0], LoggingLevel.ERROR)), 0)
def test_random_number_generators(self): model = ModelParser.parse_model( os.path.join( os.path.realpath( os.path.join(os.path.dirname(__file__), 'resources')), 'random_number_generators_test.nestml')) self.assertEqual( len( Logger.get_all_messages_of_level_and_or_node( model.get_neuron_list()[0], LoggingLevel.ERROR)), 0)
def test_invalid_element_defined_after_usage(self): model = ModelParser.parse_model( os.path.join( os.path.realpath( os.path.join(os.path.dirname(__file__), 'invalid')), 'CoCoVariableDefinedAfterUsage.nestml')) self.assertEqual( len( Logger.get_all_messages_of_level_and_or_node( model.get_neuron_list()[0], LoggingLevel.ERROR)), 1)
def test_invalid_coco_state_variables_initialized(self): """ Test that the CoCo condition is applicable for all the variables in the state block not initialized """ Logger.set_logging_level(LoggingLevel.INFO) model = ModelParser.parse_model( os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), 'invalid')), 'CoCoStateVariablesInitialized.nestml')) self.assertEqual(len( Logger.get_all_messages_of_level_and_or_node(model.get_neuron_list()[0], LoggingLevel.ERROR)), 2)