def test_notification_proto_without_login_id(mock_log):
    '''Test that a notification proto without login_id fails validation'''
    notification = NotificationRequestSingle(None, "Msg title",
                                             "Text of a message.",
                                             "some_screen_id")
    assert not NotificationRequestBatch([notification
                                         ]).validate_single(notification)
def test_valid_notification_proto(mock_log):
    '''Test that a valid notification proto is validated correctly.'''
    notification = NotificationRequestSingle(1338, "Msg title",
                                             "Text of a message.",
                                             "some_screen_id")
    assert NotificationRequestBatch([notification
                                     ]).validate_single(notification)
Ejemplo n.º 3
0
    def create_request(self, requests):
        valid_requests = []
        validator = ProtoNotificationValidator()
        for request in requests:
            if validator.validate_single(request):
                valid_requests.append(
                    NotificationRequestSingle(request.login_id, request.title,
                                              request.content))

        return NotificationRequestBatch(valid_requests)
def test_notification_proto_empty_screen_process(mocker, mock_log):
    '''Test that a valid notification proto without screen can be processed.'''
    mocker.patch('pushkin.database.database.get_raw_messages')
    notification = NotificationRequestSingle(1338, "Msg title",
                                             "Text of a message.")
    NotificationRequestBatch([notification]).process_single(notification)
    database.get_raw_messages.assert_called_with(1338, "Msg title",
                                                 "Text of a message.", "",
                                                 config.game, config.world_id,
                                                 config.dry_run)
Ejemplo n.º 5
0
    def create_request(self, requests):
        valid_requests = []
        validator = JsonNotificationValidator()
        for request in requests:
            if validator.validate_single(request):
                valid_requests.append(
                    NotificationRequestSingle(request['login_id'],
                                              request['title'],
                                              request['content']))

        return NotificationRequestBatch(valid_requests)
def test_notification_proto_empty_content(mock_log):
    '''Test that a notification proto with empty content fails validation'''
    notification = NotificationRequestSingle(1338, "Msg title", "",
                                             "some_screen_id")
    assert not NotificationRequestBatch([notification
                                         ]).validate_single(notification)
def test_notification_proto_empty_title(mock_log):
    '''Test that a notification proto with empty title fails validation'''
    notification = NotificationRequestSingle(1338, "", "Text of a message.",
                                             "some_screen_id")
    assert not NotificationRequestBatch([notification
                                         ]).validate_single(notification)