-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1457 from mozilla/fix-ga-user_purchased_premium-e…
- Loading branch information
Showing
2 changed files
with
30 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
import json | ||
|
||
from django.contrib.auth.models import User | ||
from django.test import TestCase | ||
|
||
from allauth.socialaccount.models import SocialAccount | ||
from allauth.account.models import EmailAddress | ||
from model_bakery import baker | ||
|
||
from ..views import _update_extra_data_and_email | ||
from ..views import _update_all_data | ||
|
||
|
||
class UpdateExtraDataAndEmailTest(TestCase): | ||
def test_update_extra_data_and_email(self): | ||
def test_update_all_data(self): | ||
user = baker.make(User) | ||
ea = baker.make(EmailAddress, user=user) | ||
sa = baker.make( | ||
SocialAccount, user=user, extra_data='{"test": "test"}' | ||
SocialAccount, user=user, provider='fxa', | ||
extra_data=json.loads('{"test": "test"}') | ||
) | ||
new_extra_data = '{"test": "updated"}' | ||
new_extra_data = json.loads('{"test": "updated"}') | ||
new_email = '[email protected]' | ||
|
||
response = _update_extra_data_and_email( | ||
response = _update_all_data( | ||
sa, new_extra_data, new_email | ||
) | ||
|
||
|
@@ -30,21 +33,23 @@ def test_update_extra_data_and_email(self): | |
assert sa.extra_data == new_extra_data | ||
assert ea.email == new_email | ||
|
||
def test_update_extra_data_and_email_conflict(self): | ||
extra_data='{"test": "test"}' | ||
def test_update_all_data_conflict(self): | ||
extra_data=json.loads('{"test": "test"}') | ||
|
||
user = baker.make(User, email='[email protected]') | ||
baker.make(EmailAddress, user=user, email='[email protected]') | ||
baker.make(SocialAccount, user=user, extra_data=extra_data) | ||
baker.make(SocialAccount, user=user, provider='fxa', | ||
extra_data=extra_data) | ||
|
||
user2 = baker.make(User, email='[email protected]') | ||
ea2 = baker.make(EmailAddress, user=user2, email='[email protected]') | ||
sa2 = baker.make(SocialAccount, user=user2, extra_data=extra_data) | ||
sa2 = baker.make(SocialAccount, user=user2, provider='fxa', | ||
extra_data=extra_data) | ||
|
||
new_extra_data = '{"test": "updated"}' | ||
new_extra_data = json.loads('{"test": "updated"}') | ||
new_email = '[email protected]' | ||
|
||
response = _update_extra_data_and_email( | ||
response = _update_all_data( | ||
sa2, new_extra_data, new_email | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters