Ejemplo n.º 1
0
def test_long_unicode_message():
    """ Unicode messages over 70 characters should have a split parameter """
    backend = MachBackend(name="mach", router=None, **basic_conf)
    bk = Backend.objects.create(name='long-unicode')
    connection = Connection.objects.create(identity='1112229999', backend=bk)
    text = get_random_string(200, choices=UNICODE_CHARS)
    message = OutgoingMessage(connection, text)
    data = backend.prepare_message(message)
    assert_equals(data['split'], 3)
Ejemplo n.º 2
0
def test_long_ascii_message():
    """ ASCII messages over 160 characters should have a split parameter """
    backend = MachBackend(name="mach", router=None, **basic_conf)
    bk = Backend.objects.create(name='long-ascii')
    connection = Connection.objects.create(identity='1112229999', backend=bk)
    text = get_random_string(200)
    message = OutgoingMessage(connection, text)
    data = backend.prepare_message(message)
    assert_equals(data['split'], 2)
Ejemplo n.º 3
0
def test_long_unicode_message():
    """ Unicode messages over 70 characters should have a split parameter """
    backend = MachBackend(name="mach", router=None, **basic_conf)
    bk = Backend.objects.create(name='long-unicode')
    connection = Connection.objects.create(identity='1112229999', backend=bk)
    text = get_random_string(200, choices=UNICODE_CHARS)
    message = OutgoingMessage(connection, text)
    data = backend.prepare_message(message)
    assert_equals(data['split'], 3)
Ejemplo n.º 4
0
def test_long_ascii_message():
    """ ASCII messages over 160 characters should have a split parameter """
    backend = MachBackend(name="mach", router=None, **basic_conf)
    bk = Backend.objects.create(name='long-ascii')
    connection = Connection.objects.create(identity='1112229999', backend=bk)
    text = get_random_string(200)
    message = OutgoingMessage(connection, text)
    data = backend.prepare_message(message)
    assert_equals(data['split'], 2)
Ejemplo n.º 5
0
def test_outgoing_unicode_characters():
    """ Outgoing unicode characters need to be UCS/UTF-16 encoded """
    backend = MachBackend(name="mach", router=None, **basic_conf)
    bk = Backend.objects.create(name='test')
    connection = Connection.objects.create(identity='1112229999', backend=bk)
    text = random_unicode_string(20)
    message = OutgoingMessage(connection, text)
    data = backend.prepare_message(message)
    assert_equals(data['msg'].decode(MachBackend.encoding), text)
    assert_true(data['encoding'], 'ucs')
Ejemplo n.º 6
0
def test_outgoing_unicode_characters():
    """ Outgoing unicode characters need to be UCS/UTF-16 encoded """
    backend = MachBackend(name="mach", router=None, **basic_conf)
    bk = Backend.objects.create(name='test')
    connection = Connection.objects.create(identity='1112229999', backend=bk)
    text = random_unicode_string(20)
    message = OutgoingMessage(connection, text)
    data = backend.prepare_message(message)
    assert_equals(data['msg'].decode(MachBackend.encoding), text)
    assert_true(data['encoding'], 'ucs')