Example #1
0
def test_payment_tag_removed_after_payment(resp_logged_user, active_product_item, remove_tags_mock, logged_user,
                                           tag_as_mock,
                                           mocker):
    payment = django_pagarme_facade.find_payment_by_transaction(TRANSACTION_ID)
    baker.make(django_pagarme_facade.PagarmeNotification, status=django_pagarme_facade.PAID, payment=payment)
    promote_mock = mocker.patch('pythonpro.domain.checkout_domain._promote')
    checkout_domain.payment_handler_task(payment.id)
    remove_tags_mock.assert_called_once_with(
        logged_user.email, logged_user.id, f'{active_product_item.slug}-boleto', f'{active_product_item.slug}-refused'
    )
    promote_mock.assert_called_once_with(logged_user, payment.first_item_slug())
def test_payment_linked_with_created_user(resp, django_user_model):
    User = django_user_model
    user = User.objects.first()
    payment = django_pagarme_facade.find_payment_by_transaction(
        str(TRANSACTION_ID))
    assert user == payment.user
def test_payment_linked_with_logged_user(resp_logged_user, logged_user):
    payment = django_pagarme_facade.find_payment_by_transaction(TRANSACTION_ID)
    assert logged_user == payment.user
def test_success_boleto_data(resp):
    payment = facade.find_payment_by_transaction(TRANSACTION_ID)
    assert_contains(resp, payment.boleto_barcode)
    assert_contains(resp, payment.boleto_url)
def test_pagarme_payment_initial_configuration(resp):
    payment = facade.find_payment_by_transaction(str(TRANSACTION_ID))
    assert [n.status for n in payment.notifications.all()] == [facade.WAITING_PAYMENT]
def test_send_purchase_notification(resp, send_purchase_notification_mock,
                                    active_product_item):
    if active_product_item.slug.startswith('bootcamp'):
        send_purchase_notification_mock.assert_called_once_with(
            django_pagarme_facade.find_payment_by_transaction(
                TRANSACTION_ID).id)
Example #7
0
def test_status_listener_executed(resp, payment_status_listener):
    payment = facade.find_payment_by_transaction(str(TRANSACTION_ID))
    payment_status_listener.assert_called_once_with(payment_id=payment.id)
Example #8
0
def test_notification_exists(resp):
    assert facade.find_payment_by_transaction(
        TRANSACTION_ID).notifications.exists()