mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-02 03:02:23 +02:00
Improve existing tests to check for alert notifications
This commit is contained in:
parent
0ac6e7266b
commit
119f240da4
1 changed files with 30 additions and 11 deletions
|
@ -131,8 +131,12 @@ class BudgetTestCase(IhatemoneyTestCase):
|
||||||
self.login("raclette")
|
self.login("raclette")
|
||||||
|
|
||||||
self.post_project("raclette")
|
self.post_project("raclette")
|
||||||
self.client.post("/raclette/invite",
|
resp = self.client.post("/raclette/invite",
|
||||||
data={"emails": 'alexis@notmyidea.org'})
|
data={"emails": 'alexis@notmyidea.org'},
|
||||||
|
follow_redirects=True)
|
||||||
|
|
||||||
|
# success notification
|
||||||
|
self.assertIn("Your invitations have been sent", resp.data.decode("utf-8"))
|
||||||
|
|
||||||
self.assertEqual(len(outbox), 2)
|
self.assertEqual(len(outbox), 2)
|
||||||
self.assertEqual(outbox[0].recipients, ["raclette@notmyidea.org"])
|
self.assertEqual(outbox[0].recipients, ["raclette@notmyidea.org"])
|
||||||
|
@ -212,7 +216,15 @@ class BudgetTestCase(IhatemoneyTestCase):
|
||||||
self.create_project("raclette")
|
self.create_project("raclette")
|
||||||
# Get password resetting link from mail
|
# Get password resetting link from mail
|
||||||
with self.app.mail.record_messages() as outbox:
|
with self.app.mail.record_messages() as outbox:
|
||||||
self.client.post("/password-reminder", data={"id": "raclette"})
|
resp = self.client.post(
|
||||||
|
"/password-reminder", data={"id": "raclette"}, follow_redirects=True
|
||||||
|
)
|
||||||
|
# Check that we are redirected to the right page
|
||||||
|
self.assertIn(
|
||||||
|
"A link to reset your password has been sent to you",
|
||||||
|
resp.data.decode("utf-8"),
|
||||||
|
)
|
||||||
|
# Check that an email was sent
|
||||||
self.assertEqual(len(outbox), 1)
|
self.assertEqual(len(outbox), 1)
|
||||||
url_start = outbox[0].body.find('You can reset it here: ') + 23
|
url_start = outbox[0].body.find('You can reset it here: ') + 23
|
||||||
url_end = outbox[0].body.find('.\n', url_start)
|
url_end = outbox[0].body.find('.\n', url_start)
|
||||||
|
@ -232,14 +244,21 @@ class BudgetTestCase(IhatemoneyTestCase):
|
||||||
|
|
||||||
def test_project_creation(self):
|
def test_project_creation(self):
|
||||||
with self.app.test_client() as c:
|
with self.app.test_client() as c:
|
||||||
|
with self.app.mail.record_messages() as outbox:
|
||||||
# add a valid project
|
# add a valid project
|
||||||
c.post("/create", data={
|
resp = c.post("/create", data={
|
||||||
'name': 'The fabulous raclette party',
|
'name': 'The fabulous raclette party',
|
||||||
'id': 'raclette',
|
'id': 'raclette',
|
||||||
'password': 'party',
|
'password': 'party',
|
||||||
'contact_email': 'raclette@notmyidea.org'
|
'contact_email': 'raclette@notmyidea.org'
|
||||||
})
|
}, follow_redirects=True)
|
||||||
|
# an email is sent to the owner with a reminder of the password
|
||||||
|
self.assertEqual(len(outbox), 1)
|
||||||
|
self.assertEqual(outbox[0].recipients, ["raclette@notmyidea.org"])
|
||||||
|
self.assertIn(
|
||||||
|
"A reminder email has just been sent to you",
|
||||||
|
resp.data.decode("utf-8"),
|
||||||
|
)
|
||||||
|
|
||||||
# session is updated
|
# session is updated
|
||||||
self.assertTrue(session['raclette'])
|
self.assertTrue(session['raclette'])
|
||||||
|
|
Loading…
Reference in a new issue