-
Notifications
You must be signed in to change notification settings - Fork 6
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 #1151 from maykinmedia/feature/2291-use-verified-e…
…mail [#2291 #2273 #2233] Use verified email for Laposta newsletters and Qmatic appointments
- Loading branch information
Showing
7 changed files
with
142 additions
and
25 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 |
---|---|---|
|
@@ -1041,7 +1041,10 @@ def setUp(self): | |
cms_tools.create_apphook_page(ProfileApphook) | ||
|
||
self.profile_url = reverse("profile:detail") | ||
self.user = DigidUserFactory() | ||
self.user = DigidUserFactory( | ||
email="[email protected]", verified_email="[email protected]" | ||
) | ||
self.assertTrue(self.user.has_verified_email()) | ||
|
||
self.config = LapostaConfig.get_solo() | ||
self.config.api_root = "https://laposta.local/api/v2/" | ||
|
@@ -1153,6 +1156,31 @@ def test_render_form_limit_newsletters_to_admin_selection(self, m): | |
# Second field was excluded by `LapostaConfig.limit_list_selection_to` | ||
self.assertNotIn("Nieuwsbrief2: bar", response.text) | ||
|
||
def test_do_not_render_form_if_email_not_verified(self, m): | ||
self.setUpMocks(m) | ||
|
||
self.user.verified_email = "" | ||
self.user.save() | ||
self.assertFalse(self.user.has_verified_email()) | ||
|
||
self.config.limit_list_selection_to = ["list1"] | ||
self.config.save() | ||
|
||
m.get( | ||
f"{self.config.api_root}member/{self.user.email}?list_id=list1", | ||
json={ | ||
"member": MemberFactory.build( | ||
list_id="list1", | ||
member_id="1234567", | ||
email=self.user.email, | ||
custom_fields=None, | ||
).model_dump() | ||
}, | ||
) | ||
response = self.app.get(self.profile_url, user=self.user) | ||
|
||
self.assertNotIn("newsletter-form", response.forms) | ||
|
||
|
||
@requests_mock.Mocker() | ||
@override_settings( | ||
|
@@ -1165,6 +1193,7 @@ def setUp(self): | |
super().setUp() | ||
|
||
self.data = QmaticMockData() | ||
self.assertTrue(self.data.user.has_verified_email()) | ||
|
||
def test_do_not_render_list_if_config_is_missing(self, m): | ||
self.data.config.service = None | ||
|
@@ -1194,6 +1223,15 @@ def test_do_not_render_list_if_validation_error(self, m): | |
|
||
self.assertIn(_("Geen afspraken beschikbaar"), response.text) | ||
|
||
def test_do_not_render_list_if_email_not_verified(self, m): | ||
self.data.user.verified_email = "" | ||
self.data.user.save() | ||
self.assertFalse(self.data.user.has_verified_email()) | ||
|
||
response = self.app.get(self.appointments_url, user=self.data.user) | ||
|
||
self.assertIn(_("Geen afspraken beschikbaar"), response.text) | ||
|
||
def test_render_list_if_appointments_are_found(self, m): | ||
self.data.setUpMocks(m) | ||
|
||
|
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
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
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
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
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
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 |
---|---|---|
|
@@ -11,7 +11,10 @@ | |
class QmaticMockData: | ||
def __init__(self): | ||
self.appointments_url = reverse("profile:appointments") | ||
self.user = DigidUserFactory() | ||
self.user = DigidUserFactory( | ||
email="[email protected]", | ||
verified_email="[email protected]", | ||
) | ||
|
||
self.config = QmaticConfig.get_solo() | ||
self.config.booking_base_url = "https://qmatic.local/" | ||
|