-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Makes sure we're not accidentally doubling up somewhere
- Loading branch information
Henry Walshaw
committed
Sep 10, 2024
1 parent
cfeba33
commit 48ff5f7
Showing
1 changed file
with
10 additions
and
5 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 |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
from resourceauth import ResourceAuth | ||
import result | ||
|
||
|
||
TEST_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
|
||
|
@@ -95,26 +96,30 @@ def testRunResoures(self): | |
(resource.url, str(resource.runs[0]))) | ||
|
||
def testNotificationsApi(self): | ||
Rcp = Recipient | ||
test_emails = ['[email protected]', '[email protected]', '[email protected]'] | ||
invalid_emails = ['invalid', None, object()] | ||
|
||
# invalid values should raise exception | ||
for email in invalid_emails: | ||
with self.assertRaises(ValueError): | ||
Rcp.get_or_create('email', email) | ||
Recipient.get_or_create('email', email) | ||
|
||
for email in test_emails: | ||
Rcp.get_or_create('email', email) | ||
from_db = set(r[0] for r in DB.session.query(Rcp.location).all()) | ||
Recipient.get_or_create('email', email) | ||
from_db = { | ||
r[0] | ||
for r in DB.session.query(Recipient.location).filter( | ||
Recipient.channel == 'email' | ||
) | ||
} | ||
self.assertEqual(from_db, set(test_emails)) | ||
|
||
r = Resource.query.first() | ||
r.set_recipients('email', test_emails[:2]) | ||
|
||
# unused email should be removed | ||
self.assertEqual(set(r.get_recipients('email')), set(test_emails[:2])) | ||
q = Rcp.query.filter(Rcp.location == test_emails[-1]) | ||
q = Recipient.query.filter(Recipient.location == test_emails[-1]) | ||
self.assertEqual(q.count(), 0) | ||
|
||
def testWebhookNotifications(self): | ||
|