Esempio n. 1
0
def test_adding_new_payment_is_reflected_on_pending_payments_list(
        facade: PaymentsFacade, connection: Connection,
        event_bus: Mock) -> None:
    customer_id = 1
    assert facade.get_pending_payments(customer_id) == []

    payment_uuid = uuid.uuid4()
    amount = get_dollars("15.00")
    description = "Example"
    # with patch.object(event_bus, "post") as post_mock:
    facade.start_new_payment(payment_uuid, customer_id, amount, description)

    (row, ) = connection.execute(payments.select()).fetchall()
    assert dict(row) == {
        "uuid": str(payment_uuid),
        "customer_id": customer_id,
        "amount": int(amount.amount * 100),
        "currency": amount.currency.iso_code,
        "status": PaymentStatus.NEW.value,
        "description": description,
        "charge_id": None,
    }

    pending_payments = facade.get_pending_payments(customer_id)

    assert pending_payments == [
        PaymentDto(payment_uuid, amount, description, PaymentStatus.NEW.value)
    ]
    event_bus.post.assert_called_once_with(
        PaymentStarted(payment_uuid, customer_id))
Esempio n. 2
0
def test_pending_payments_returns_only_new_payments(
        facade: PaymentsFacade, inserted_payment: dict,
        connection: Connection) -> None:
    assert facade.get_pending_payments(inserted_payment["customer_id"]) == []