Exemplo n.º 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,
        )
Exemplo n.º 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,
        )
Exemplo n.º 3
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,
        )
Exemplo n.º 4
0
def test_require_different_publisher(message):
    batch_identifier = get_operation(message).batch_identifier

    require_different_publisher(
        Committed(
            uuid.uuid1().bytes,  # change the publisher
            batch_identifier,
        ),
        message,
    )

    with pytest.raises(InvalidPublisher):
        require_different_publisher(
            Committed(
                message.header.publisher,
                batch_identifier,
            ),
            message,
        )
Exemplo n.º 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,
        )
Exemplo n.º 6
0
def test_require_different_publisher(message):
    batch_identifier = get_operation(message).batch_identifier

    require_different_publisher(
        Committed(
            uuid.uuid1().bytes,  # change the publisher
            batch_identifier,
        ),
        message,
    )

    with pytest.raises(InvalidPublisher):
        require_different_publisher(
            Committed(
                message.header.publisher,
                batch_identifier,
            ),
            message,
        )