def test_model_perform_logging(self): model = QuadraticEquationViewModel() model.set_a(2) model.set_b(4) model.set_c(2) model.perform() self.assertEqual('Result = Answer:\n x = -1.0', model.logger.get_last_message())
def test_input_wrong_data(self): model = QuadraticEquationViewModel() model.set_a('@1') model.set_b(4) model.set_c(2) model.perform() wrong_message = 'Incorrect input' self.assertEqual(wrong_message, model.logger.get_last_message())
def test_correct_set_value(self): model = QuadraticEquationViewModel() model.set_a(1) model.set_b(10) model.set_c(-12) self.assertEqual(1, model.get_a()) self.assertEqual(10, model.get_b()) self.assertEqual(-12, model.get_c())
def test_model_perform_all_message_logging(self): model = QuadraticEquationViewModel() model.set_a(2) model.set_b(4) model.set_c(2) model.perform() log_message = [ 'Setting a = 2', 'Setting b = 4', 'Setting c = 2', 'Button clicked', 'a = 2, b = 4, c = 2', 'Result = Answer:\n x = -1.0' ] self.assertEqual(log_message, model.logger.get_log_messages()[-6:])
def test_set_b_logging(self): model = QuadraticEquationViewModel() model.set_b(2) self.assertEqual('Setting b = 2', model.logger.get_last_message())
def test_when_clear_b_button_disabled(self): model = QuadraticEquationViewModel(1, -1, 1) model.set_b(None) self.assertEqual('disabled', model.is_button_enable())