API: Allow to send activation email when creating customers (#2729)

Co-authored-by: Raphael Michel <michel@rami.io>
This commit is contained in:
Michael Stapelberg
2022-07-25 12:16:48 +02:00
committed by GitHub
parent f3a77d8154
commit 0d407ce36f
6 changed files with 74 additions and 22 deletions

View File

@@ -20,6 +20,7 @@
# <https://www.gnu.org/licenses/>.
#
import pytest
from django.core import mail as djmail
from django_scopes import scopes_disabled
@@ -98,6 +99,29 @@ def test_customer_create(token_client, organizer):
assert customer.is_active
assert customer.name == 'John Doe'
assert customer.is_verified
assert len(djmail.outbox) == 0
@pytest.mark.django_db
def test_customer_create_send_email(token_client, organizer):
resp = token_client.post(
'/api/v1/organizers/{}/customers/'.format(organizer.slug),
format='json',
data={
'identifier': 'IGNORED',
'email': 'bar@example.com',
'name_parts': {
"_scheme": "given_family",
'given_name': 'John',
'family_name': 'Doe',
},
'is_active': True,
'is_verified': True,
'send_email': True,
}
)
assert resp.status_code == 201
assert len(djmail.outbox) == 1
@pytest.mark.django_db