API: Fix validation of duplicate customer email addresses

This commit is contained in:
Raphael Michel
2023-08-30 14:25:42 +02:00
parent 2e8447486c
commit 53e84dfb08
2 changed files with 36 additions and 0 deletions

View File

@@ -104,6 +104,34 @@ def test_customer_create(token_client, organizer):
assert len(djmail.outbox) == 0
@pytest.mark.django_db
def test_customer_create_email_unique(token_client, organizer):
resp = token_client.post(
'/api/v1/organizers/{}/customers/'.format(organizer.slug),
format='json',
data={
'identifier': 'IGNORED',
'email': 'bar@example.com',
'password': 'foobar',
'is_active': True,
'is_verified': True,
}
)
assert resp.status_code == 201
resp = token_client.post(
'/api/v1/organizers/{}/customers/'.format(organizer.slug),
format='json',
data={
'identifier': 'IGNORED',
'email': 'bar@example.com',
'password': 'foobar',
'is_active': True,
'is_verified': True,
}
)
assert resp.status_code == 400
@pytest.mark.django_db
def test_customer_create_send_email(token_client, organizer):
resp = token_client.post(