def test_status_start_time_gives_start_time(self, mock_datetime): start_time = self.real_datetime(2012,1,1,8,0,0) mock_datetime.now.return_value = start_time status = MachineStatus() actual = status.status()['start_time'] self.assertEqual(start_time,actual)
def test_status_elapsed_time_gives_elapsed_time_in_seconds(self, mock_datetime): expected = self.real_timedelta(seconds = 10) values = [self.real_datetime(2012,1,1,8,0,0), self.real_datetime(2012,1,1,8,0,10)] def next_values(): return values.pop(0) mock_datetime.now.side_effect = next_values status = MachineStatus() actual = status.status()['elapsed_time'] self.assertEqual(expected,actual)
def test_add_error_adds_an_error(self,mock_datetime): mock_time = self.real_datetime(2012,1,1,8,0,0) mock_datetime.now.return_value = mock_time message = "Message" expected = [{ 'layer' : None, 'time': mock_time, 'message': message, }] status = MachineStatus() status.add_error(MachineError(message)) self.assertEqual(expected,status.status()['errors'])
def test_status_is_running_after_first_drip(self): status = MachineStatus() status.drip_call_back(1,1) self.assertEqual('Running',status.status()['status'])
def test_status_is_starting_before_first_drip(self): status = MachineStatus() self.assertEqual('Starting',status.status()['status'])
def test_skipped_layer_adds_a_skipped_layer(self): status = MachineStatus() status.skipped_layer() self.assertEqual(1,status.status()['skipped_layers'])
def test_status_is_running_after_first_drip(self): status = MachineStatus() status.drip_call_back(1,1,1) self.assertEqual('Running',status.status()['status'])
def test_set_model_height_update_height_of_layer(self): status = MachineStatus() status.set_model_height(7.12213) self.assertEqual(7.12213,status.status()['model_height'])
def test_once_complete_drips_or_layers_dont_change_status(self): status = MachineStatus() status.set_complete() status.add_layer() status.drip_call_back(45,10) self.assertEqual('Complete',status.status()['status'])
def test_not_waiting_for_drips_sets_waiting(self): status = MachineStatus() status.set_not_waiting_for_drips() self.assertEqual(False,status.status()['waiting_for_drips'])
def test_add_error_adds_an_error(self): status = MachineStatus() status.add_error(MachineError("Error", "Test Error")) self.assertEqual(1,status.status()['errors'])
def test_once_complete_drips_or_layers_dont_change_status(self): status = MachineStatus() status.set_complete() status.add_layer() status.drip_call_back(45,10,12) self.assertEqual('Complete',status.status()['status'])
def test_set_complete_makes_status_complete(self): status = MachineStatus() status.set_complete() self.assertEqual('Complete',status.status()['status'])
def test_status_is_running_after_first_layer(self): status = MachineStatus() status.add_layer() self.assertEqual('Running',status.status()['status'])
def test_drip_call_back_updates_height(self): status = MachineStatus() status.drip_call_back(67,12,12.2) self.assertEqual(12, status.status()['height']) self.assertEqual(67, status.status()['drips']) self.assertEqual(12.2, status.status()['drips_per_second'])
def test_add_layer_adds_a_layer(self): status = MachineStatus() status.add_layer() self.assertEqual(1,status.status()['current_layer'])
def test_drip_call_back_updates_height(self): status = MachineStatus() status.drip_call_back(67,12) self.assertEqual(12, status.status()['height']) self.assertEqual(67, status.status()['drips'])