Esempio n. 1
0
def test_login_and_then_other_event(setup, mocker):
    '''Tests that both devices are persisted if they have different tokens'''
    context.event_handler_manager = EventHandlerManager()

    event_batch_platform1 = create_batch_with_login_event(user_id=1338, platform_id=1, device_id='str_device_id_1',
                                                          device_token='str_device_token_1')
    event_request_platform1 = EventRequestBatch([event_batch_platform1])
    event_request_platform1.process()

    # test no message
    event1 = EventRequestSingle(1, -1, None, 1442502890000)
    event_request_other1 = EventRequestBatch([event1])
    messages1 = event_request_other1.build_messages()
    assert len(messages1) == 0

    # test parameter from event
    params = {'title_param': 'param title', 'text_param': 'param content'}
    event2 = EventRequestSingle(user_id=1, event_id=3, pairs=params, timestamp=1442502890000)
    event_request_other2 = EventRequestBatch([event2])
    messages2 = event_request_other2.build_messages()
    assert len(messages2) == 1
    assert messages2[0]['message_id'] == 4
    assert messages2[0]['content'] == 'text param content'
    assert messages2[0]['title'] == 'title param title'

    # test missing parameter which is required by localization
    event3 = EventRequestSingle(user_id=1, event_id=3, pairs=None, timestamp=1442502890000)
    event_request_other3 = EventRequestBatch([event3])
    messages3 = event_request_other3.build_messages()
    assert len(messages3) == 0
Esempio n. 2
0
def test_build_messages_multiple_event_msg(setup):
    context.event_handler_manager = EventHandlerManager()
    single_request = EventRequestSingle(1, 1, {}, 1442502890000)
    request = EventRequestBatch([single_request])
    messages = request.build_messages()
    print messages
    assert len(messages) == 2
    assert set([message['message_id'] for message in messages]) == {1, 2}
Esempio n. 3
0
def test_build_messages_multiple_event_msg(setup):
    context.event_handler_manager = EventHandlerManager()
    single_request = EventRequestSingle(1, 1, {}, 1442502890000)
    request = EventRequestBatch([single_request])
    messages = request.build_messages()
    print messages
    assert len(messages) == 2
    assert set([message['message_id'] for message in messages]) == {1, 2}
Esempio n. 4
0
def test_build_messages_single_event_msg(setup):
    context.event_handler_manager = EventHandlerManager()
    single_request = EventRequestSingle(1, 2, {}, 1442502890000)
    request = EventRequestBatch([single_request])
    messages = request.build_messages()
    print messages
    assert len(messages) == 1
    assert messages[0]['message_id'] == 3
Esempio n. 5
0
def test_build_messages_single_event_msg(setup):
    context.event_handler_manager = EventHandlerManager()
    single_request = EventRequestSingle(1, 2, {}, 1442502890000)
    request = EventRequestBatch([single_request])
    messages = request.build_messages()
    print messages
    assert len(messages) == 1
    assert messages[0]['message_id'] == 3
Esempio n. 6
0
def test_build_messages_missing_event(setup):
    context.event_handler_manager = EventHandlerManager()
    event_proto = EventMessage_pb2.Event()
    event_proto.user_id = 1
    event_proto.event_id = 5
    event_proto.event_type = 2
    event_proto.timestamp = 1442502890000
    request = EventRequestBatch([event_proto])
    assert len(request.build_messages()) == 0
Esempio n. 7
0
def test_build_messages_missing_event(setup):
    context.event_handler_manager = EventHandlerManager()
    event_proto = EventMessage_pb2.Event()
    event_proto.user_id = 1
    event_proto.event_id = 5
    event_proto.event_type = 2
    event_proto.timestamp = 1442502890000
    request = EventRequestBatch([event_proto])
    assert len(request.build_messages()) == 0
Esempio n. 8
0
def test_build_messages_multiple_event_msg(setup):
    context.event_handler_manager = EventHandlerManager()
    event_proto = EventMessage_pb2.Event()
    event_proto.user_id = 1
    event_proto.event_id = 1
    event_proto.event_type = 2
    event_proto.timestamp = 1442502890000
    request = EventRequestBatch([event_proto])
    messages = request.build_messages()
    print messages
    assert len(messages) == 2
    assert set([message['message_id'] for message in messages]) == {1, 2}
Esempio n. 9
0
def test_build_messages_single_event_msg(setup):
    context.event_handler_manager = EventHandlerManager()
    event_proto = EventMessage_pb2.Event()
    event_proto.user_id = 1
    event_proto.event_id = 2
    event_proto.event_type = 2
    event_proto.timestamp = 1442502890000
    request = EventRequestBatch([event_proto])
    messages = request.build_messages()
    print messages
    assert len(messages) == 1
    assert messages[0]['message_id'] == 3
Esempio n. 10
0
def test_build_messages_multiple_event_msg(setup):
    context.event_handler_manager = EventHandlerManager()
    event_proto = EventMessage_pb2.Event()
    event_proto.user_id = 1
    event_proto.event_id = 1
    event_proto.event_type = 2
    event_proto.timestamp = 1442502890000
    request = EventRequestBatch([event_proto])
    messages = request.build_messages()
    print messages
    assert len(messages) == 2
    assert set([message['message_id'] for message in messages]) == {1, 2}
Esempio n. 11
0
def test_build_messages_single_event_msg(setup):
    context.event_handler_manager = EventHandlerManager()
    event_proto = EventMessage_pb2.Event()
    event_proto.user_id = 1
    event_proto.event_id = 2
    event_proto.event_type = 2
    event_proto.timestamp = 1442502890000
    request = EventRequestBatch([event_proto])
    messages = request.build_messages()
    print messages
    assert len(messages) == 1
    assert messages[0]['message_id'] == 3
Esempio n. 12
0
def test_login_and_then_other_event(setup, mocker):
    '''Tests that both devices are persisted if they have different tokens'''
    context.event_handler_manager = EventHandlerManager()

    event_batch_platform1 = create_batch_with_login_event(user_id=1338, platform_id=1, device_id='str_device_id_1',
                                                          device_token='str_device_token_1')
    event_request_platform1 = EventRequestBatch([event_batch_platform1])
    event_request_platform1.process()

    # test no message
    event3 = EventRequestSingle(1, -1, None, 1442502890000)
    event_request_other3 = EventRequestBatch([event3])
    messages3 = event_request_other3.build_messages()
    assert len(messages3) == 0
Esempio n. 13
0
def test_login_and_then_other_event(setup, mocker):
    '''Tests that both devices are persisted if they have different tokens'''
    context.event_handler_manager = EventHandlerManager()

    event_batch_platform1 = create_batch_with_login_event(
        user_id=1338, platform_id=1, device_token='str_device_token_1')
    event_request_platform1 = EventRequestBatch([event_batch_platform1])
    event_request_platform1.process()

    # test no message
    event1 = EventRequestSingle(1, -1, None, 1442502890000)
    event_request_other1 = EventRequestBatch([event1])
    messages1 = event_request_other1.build_messages()
    assert len(messages1) == 0

    # test parameter from event
    params = {'title_param': 'param title', 'text_param': 'param content'}
    event2 = EventRequestSingle(user_id=1,
                                event_id=3,
                                pairs=params,
                                timestamp=2442502890000)
    event_request_other2 = EventRequestBatch([event2])
    messages2 = event_request_other2.build_messages()
    assert len(messages2) == 1
    assert messages2[0]['message_id'] == 4
    assert messages2[0]['content'] == 'text param content'
    assert messages2[0]['title'] == 'title param title'

    # test missing parameter which is required by localization
    event3 = EventRequestSingle(user_id=1,
                                event_id=3,
                                pairs=None,
                                timestamp=1442502890000)
    event_request_other3 = EventRequestBatch([event3])
    messages3 = event_request_other3.build_messages()
    assert len(messages3) == 0
Esempio n. 14
0
def test_login_and_then_other_event(setup, mocker):
    '''Tests that both devices are persisted if they have different tokens'''
    context.event_handler_manager = EventHandlerManager()

    event_batch_platform1 = create_batch_with_login_event(
        user_id=1338,
        platform_id=1,
        device_id='str_device_id_1',
        device_token='str_device_token_1')
    event_request_platform1 = EventRequestBatch([event_batch_platform1])
    event_request_platform1.process()

    # test no message
    event3 = EventRequestSingle(1, -1, None, 1442502890000)
    event_request_other3 = EventRequestBatch([event3])
    messages3 = event_request_other3.build_messages()
    assert len(messages3) == 0
Esempio n. 15
0
def test_build_messages_missing_event(setup):
    context.event_handler_manager = EventHandlerManager()
    single_request = EventRequestSingle(1, 5, {}, 1442502890000)
    request = EventRequestBatch([single_request])
    assert len(request.build_messages()) == 0
Esempio n. 16
0
def test_build_messages_missing_event(setup):
    context.event_handler_manager = EventHandlerManager()
    single_request = EventRequestSingle(1, 5, {}, 1442502890000)
    request = EventRequestBatch([single_request])
    assert len(request.build_messages()) == 0