def test_headset_2(self):
     """
     Test recording state after streaming start and setting of filename
     """
     model = ApplicationModel()
     model.start_headsets()
     self.assertFalse(model.is_recording(), "Should not be recording")
     model.stop_headsets()
 def _test_headset_2(self, serial_mock):
     """
     Test stopping of streaming
     """
     model = ApplicationModel()
     model.select_port(0, "__test_port_name__")
     model.headsets[0].start()
     model.stop_headsets()
     self.assertFalse(model.is_headset_streaming(), "Should not be streaming from headset")
 def _test_headset_3(self, serial_mock):
     """
     Test starting of toggle streaming
     """
     model = ApplicationModel()
     model.select_port(0, "__test_port_name__")
     model.start_headsets()
     time.sleep(.1)
     self.assertTrue(model.is_headset_streaming(), "Should be streaming from headset")
     model.stop_headsets()
 def _test_headset_2(self, serial_mock):
     """
     Test stopping of streaming
     """
     model = ApplicationModel()
     model.select_port(0, "__test_port_name__")
     model.headsets[0].start()
     model.stop_headsets()
     self.assertFalse(model.is_headset_streaming(),
                      "Should not be streaming from headset")
 def _test_headset_3(self, serial_mock):
     """
     Test starting of toggle streaming
     """
     model = ApplicationModel()
     model.select_port(0, "__test_port_name__")
     model.start_headsets()
     time.sleep(.1)
     self.assertTrue(model.is_headset_streaming(),
                     "Should be streaming from headset")
     model.stop_headsets()
 def test_headset_4(self):
     """
     Test recording state after streaming start
     """
     record_time = 10
     
     model = ApplicationModel()
     model.start_headsets()
     model.start_recording(record_time)
     model.stop_recording()
     model.stop_headsets()
     self.assertFalse(model.is_recording(), "Should not be recording")
Example #7
0
class TestApplicationModelSimulation( unittest.TestCase ):

    def setUp(self):
        unittest.TestCase.setUp(self)
        
        self.model = ApplicationModel()
        
        _eeg_type = 1
        
        [ mat, frequencies ] = HDFReader().read( filenames[6][0] )
        data = [ np.asarray( mat[i-1][ _eeg_type ] ) for i in range(1,9) ]  
        
        interval = 1. / frequencies[_eeg_type]  
        
        self.model.simulators[0].set_simulation_data(data)
        self.model.simulators[0].set_simulation_interval(interval)
        
        eeg_chans = ['/eega0/channel_%d/pp' % i for i in range(1,9) ]
        
        self.model.simulators[0].set_patterns( eeg_chans )
    
    def _test_modelstate_1(self):
        self.model.start_simulation()
        self.assertEquals( self.model.get_simulation_state(), DataSimulator.PLAYING )
        self.model.stop_simulation()
        
    def _test_modelstate_2(self):
        self.model.start_simulation()
        self.model.stop_simulation()
        self.assertEquals( self.model.get_simulation_state(), DataSimulator.IDLE )
         
    def _test_modelstate_3(self):
        self.model.start_simulation()
        self.model.pause_simulation()
        sleep( .2 )
        self.assertEquals( self.model.get_simulation_state(), DataSimulator.PAUSED )
        self.model.stop_simulation()
         
    def _test_modelstate_4(self):
        self.model.pause_simulation()
        self.assertEquals( self.model.get_simulation_state(), DataSimulator.IDLE )
        
    def tearDown(self):
        unittest.TestCase.tearDown(self)
        self.model.stop_simulation()
        self.model.stop_recording()
        self.model.stop_headsets()