Example #1
0
def test_require_batch_id_not_advanced_if_same_node(message):
    batch_identifier = get_operation(message).batch_identifier

    require_batch_id_not_advanced_if_same_node(
        RolledBack(
            message.header.publisher,
            batch_identifier,
        ),
        message,
    )

    require_batch_id_not_advanced_if_same_node(
        RolledBack(
            message.header.publisher,
            copy(batch_identifier, node=uuid.uuid1().bytes),
        ),
        message,
    )

    with pytest.raises(InvalidBatch):
        require_batch_id_not_advanced_if_same_node(
            RolledBack(
                message.header.publisher,
                copy(batch_identifier, id=batch_identifier.id + 1),
            ),
            message,
        )
Example #2
0
def test_require_batch_id_not_advanced_if_same_node(message):
    batch_identifier = get_operation(message).batch_identifier

    require_batch_id_not_advanced_if_same_node(
        RolledBack(
            message.header.publisher,
            batch_identifier,
        ),
        message,
    )

    require_batch_id_not_advanced_if_same_node(
        RolledBack(
            message.header.publisher,
            copy(batch_identifier, node=uuid.uuid1().bytes),
        ),
        message,
    )

    with pytest.raises(InvalidBatch):
        require_batch_id_not_advanced_if_same_node(
            RolledBack(
                message.header.publisher,
                copy(batch_identifier, id=batch_identifier.id + 1),
            ),
            message,
        )
Example #3
0
def test_require_batch_advanced_if_same_node(message):
    batch_identifier = get_operation(message).batch_identifier

    require_batch_id_advanced_if_same_node(
        Committed(
            publisher=message.header.publisher,
            batch_identifier=copy(batch_identifier, node=uuid.uuid1().bytes),
        ),
        0,
        message,
    )

    require_batch_id_advanced_if_same_node(
        Committed(
            publisher=message.header.publisher,
            batch_identifier=copy(batch_identifier, id=batch_identifier.id - 1),
        ),
        0,
        message,
    )

    with pytest.raises(InvalidBatch):
        require_batch_id_advanced_if_same_node(
            Committed(
                publisher=message.header.publisher,
                batch_identifier=batch_identifier,
            ),
            0,
            message,
        )
Example #4
0
def test_require_same_batch(message):
    batch_identifier = get_operation(message).batch_identifier

    require_same_batch(
        InTransaction(
            message.header.publisher,
            batch_identifier,
        ),
        message,
    )

    with pytest.raises(InvalidBatch):
        require_same_batch(
            InTransaction(
                message.header.publisher,
                copy(batch_identifier, id=batch_identifier.id + 1),
            ),
            message,
        )
Example #5
0
def test_require_same_batch(message):
    batch_identifier = get_operation(message).batch_identifier

    require_same_batch(
        InTransaction(
            message.header.publisher,
            batch_identifier,
        ),
        message,
    )

    with pytest.raises(InvalidBatch):
        require_same_batch(
            InTransaction(
                message.header.publisher,
                copy(batch_identifier, id=batch_identifier.id + 1),
            ),
            message,
        )