Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix subscription creation webhook failing due to case sensitivity iss… #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion djpaddle/mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def subscriber_by_payload(Subscriber, payload):
"""
if "email" not in payload:
raise Subscriber.DoesNotExist("'email' missing in payload")
return Subscriber.objects.get(email=payload["email"])
return Subscriber.objects.get(email__iexact=payload["email"])


def subscriptions_by_subscriber(subscriber, queryset):
Expand Down
16 changes: 15 additions & 1 deletion tests/test_mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,27 @@


class TestPaddleMappers(TestCase):
def test_get_subscriber_by_payload(self):
def test_get_subscriber_by_payload_does_not_exist(self):
Subscriber = settings.get_subscriber_model()
payload = {"email": "[email protected]"}

with self.assertRaises(Subscriber.DoesNotExist):
mappers.get_subscriber_by_payload(Subscriber, payload)

def test_get_subscriber_by_payload(self):
Subscriber = settings.get_subscriber_model()
subscriber = Subscriber.objects.create(username="user", email="[email protected]")
payload = {"email": "[email protected]"}
fetched_subscriber = mappers.get_subscriber_by_payload(Subscriber, payload)
self.assertEqual(fetched_subscriber.email, subscriber.email)

def test_get_subscriber_by_payload_case_sensitive(self):
Subscriber = settings.get_subscriber_model()
subscriber = Subscriber.objects.create(username="user", email="[email protected]")
payload = {"email": "[email protected]"}
fetched_subscriber = mappers.get_subscriber_by_payload(Subscriber, payload)
self.assertEqual(fetched_subscriber.email, subscriber.email)

def test_get_subscriber_by_payload_missing_email(self):
Subscriber = settings.get_subscriber_model()
payload = {"not-email": "[email protected]"}
Expand Down