示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
    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)
示例#6
0
    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)
示例#7
0
    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)
示例#8
0
    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)
示例#9
0
    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)
示例#10
0
    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)
示例#11
0
    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)
示例#12
0
    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)
示例#13
0
 def test_handle_message_content_should_not_throw(self):
     confirmationshandler.handle_message_content('user', 'content')
示例#14
0
    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)