def test_when_message_has_sent_command_should_save_send_confirmation( self, message, save_send_confirmation): user = '******' expected_args = (user, datetime.datetime(2012, 1, 14, 12, 12)) confirmationshandler.handle_message_content(user, message) args, _ = save_send_confirmation.call_args assert_true(save_send_confirmation.called) assert_equals(args, expected_args)
def test_when_message_has_received_command_should_save_received_confirmation(self, save_received_confirmation, get_participants): user = '******' message = 'otrzymano' expected_args = (user, datetime.datetime(2012, 1, 14, 12, 12)) get_participants.return_value = [user] confirmationshandler.handle_message_content(user, message) args, _ = save_received_confirmation.call_args assert_true(save_received_confirmation.called) assert_equals(args, expected_args)
def test_when_successfully_saved_sent_confirmation_should_return_sent_confirmation_saved_test( self, message, save_send_confirmation): user = '******' answer = confirmationshandler.handle_message_content(user, message) assert_equal(answer, strings.sent_confirmation_saved)
def test_when_there_is_error_on_saving_sent_confirmation_should_return_error_text(self, message, save_send_confirmation, get_participants): user = '******' save_send_confirmation.side_effect = Exception answer = confirmationshandler.handle_message_content(user, message) assert_equal(answer, strings.error_text)
def test_when_successfully_saved_sent_confirmation_should_return_sent_confirmation_saved_test(self, message, save_send_confirmation, get_participants): user = '******' get_participants.return_value = [user] answer = confirmationshandler.handle_message_content(user, message) assert_equal(answer, strings.sent_confirmation_saved)
def test_when_got_confirmation_from_user_not_in_paritipants_list_should_return_not_a_participant_text(self, message, save_received_confirmation, get_participants): user = '******' get_participants.return_value = ['otherUser', 'alsoOtherUser', 'differentUserAsWell'] answer = confirmationshandler.handle_message_content(user, message) assert_equal(answer, strings.not_a_participant)
def test_when_saving_duplicated_confirmation_should_return_confirmation_already_exists_text( self, message, save_send_confirmation): user = '******' save_send_confirmation.side_effect = IntegrityError answer = confirmationshandler.handle_message_content(user, message) assert_equal(answer, strings.confirmation_already_exists)
def test_when_there_is_error_on_savind_received_confirmation_should_return_error_text( self, save_received_confirmation): user = '******' message = 'otrzymano' save_received_confirmation.side_effect = Exception answer = confirmationshandler.handle_message_content(user, message) assert_equal(answer, strings.error_text)
def test_when_saving_duplicated_confirmation_should_return_confirmation_already_exists_text(self, save_received_confirmation, get_participants): user = '******' message = 'otrzymano' save_received_confirmation.side_effect = IntegrityError get_participants.return_value = [user] answer = confirmationshandler.handle_message_content(user, message) assert_equal(answer, strings.confirmation_already_exists)
def test_when_message_has_add_command_should_not_try_to_save_any_confirmation( self, save_send_confirmation, save_received_confirmation): confirmationshandler.handle_message_content('user', 'dodaj adres') assert_false(save_send_confirmation.called) assert_false(save_received_confirmation.called)
def test_when_message_has_add_command_should_return_data_gathering_disabled_text( self): answer = confirmationshandler.handle_message_content( 'user', 'dodaj adres') assert_equal(answer, strings.data_gathering_disabled)
def test_when_message_has_unknown_command_should_return_help_text(self): answer = confirmationshandler.handle_message_content( 'user', 'djinfdushfdushfcvuidhfuhv') assert_equal(answer, strings.help_text)
def test_handle_message_content_should_not_throw(self): confirmationshandler.handle_message_content('user', 'content')
def test_when_command_has_different_letter_case_should_also_recognize_it(self, message, save_send_confirmation, save_received_confirmation, get_participants): user = '******' answer = confirmationshandler.handle_message_content(user, message) assert_not_equal(answer, strings.help_text)