def test_good_message(): """ Make sure backend creates IncomingMessage properly """ backend = MachBackend(name="mach", router=None, **basic_conf) data = {'snr': '1112229999', 'msg': 'Hi'} message = backend.message(data) assert_true(isinstance(message, IncomingMessage)) assert_true(isinstance(message.connection, Connection)) assert_equals(message.connection.identity, data['snr']) assert_equals(message.text, data['msg'])
def test_incoming_unicode_characters(): backend = MachBackend(name="mach", router=None, **basic_conf) text = random_unicode_string(20) data = {'snr': '1112229999', 'msg': text} message = backend.message(data) assert_equals(text, message.text)
def test_bad_message(): """ Don't die if POSTed data doesn't contain the necessary items """ backend = MachBackend(name="mach", router=None, **basic_conf) data = {'foo': 'moo'} message = backend.message(data) assert_equals(message, None)