Example #1
0
    def test_reset_brain(self, mock_get_brain_info):
        simulations[0].cle = mock.MagicMock()

        class Foo(object):
            pass
        result = Foo()
        result.error_message = ""
        simulations[0].cle.set_simulation_brain.return_value = result
        mock_get_brain_info.return_value = os.path.join(PATH,
                                                        'models/braitenberg.py'), None, {u'record': slice(0L, 2L, 1L), u'neurons': slice(0L, 2L, 1L)}

        SimulationResetStorage.resetBrain(simulations[0], 'expId', 'contextId')
        SimulationResetStorage._get_brain_info_from_storage.assert_called_with('expId', 'contextId')
Example #2
0
    def test_reset_brain_throw(self, mock_get_brain_info):
        simulations[0].cle = mock.MagicMock()

        class Foo(object):
            pass
        result = Foo()
        result.error_message = "error"
        result.error_line = 10
        result.error_column = 50
        result.handle_population_change = None
        simulations[0].cle.set_simulation_brain.return_value = result
        mock_get_brain_info.return_value = os.path.join(PATH,
                                                        'models/braitenberg.py'), None, {u'record': slice(0L, 2L, 1L), u'neurons': slice(0L, 2L, 1L)}
        with self.assertRaises(ROSCLEClientException) as context:
            SimulationResetStorage.resetBrain(simulations[0], 'expId', 'contextId')

        self.assertEqual(
            'error, line:10, column:50, population_change:None', context.exception.message)