|
42 | 42 | from resourceauth import ResourceAuth |
43 | 43 | import result |
44 | 44 |
|
| 45 | + |
45 | 46 | TEST_DIR = os.path.dirname(os.path.abspath(__file__)) |
46 | 47 |
|
47 | 48 |
|
@@ -95,26 +96,30 @@ def testRunResoures(self): |
95 | 96 | (resource.url, str(resource.runs[0]))) |
96 | 97 |
|
97 | 98 | def testNotificationsApi(self): |
98 | | - Rcp = Recipient |
99 | 99 | |
100 | 100 | invalid_emails = ['invalid', None, object()] |
101 | 101 |
|
102 | 102 | # invalid values should raise exception |
103 | 103 | for email in invalid_emails: |
104 | 104 | with self.assertRaises(ValueError): |
105 | | - Rcp.get_or_create('email', email) |
| 105 | + Recipient.get_or_create('email', email) |
106 | 106 |
|
107 | 107 | for email in test_emails: |
108 | | - Rcp.get_or_create('email', email) |
109 | | - from_db = set(r[0] for r in DB.session.query(Rcp.location).all()) |
| 108 | + Recipient.get_or_create('email', email) |
| 109 | + from_db = { |
| 110 | + r[0] |
| 111 | + for r in DB.session.query(Recipient.location).filter( |
| 112 | + Recipient.channel == 'email' |
| 113 | + ) |
| 114 | + } |
110 | 115 | self.assertEqual(from_db, set(test_emails)) |
111 | 116 |
|
112 | 117 | r = Resource.query.first() |
113 | 118 | r.set_recipients('email', test_emails[:2]) |
114 | 119 |
|
115 | 120 | # unused email should be removed |
116 | 121 | self.assertEqual(set(r.get_recipients('email')), set(test_emails[:2])) |
117 | | - q = Rcp.query.filter(Rcp.location == test_emails[-1]) |
| 122 | + q = Recipient.query.filter(Recipient.location == test_emails[-1]) |
118 | 123 | self.assertEqual(q.count(), 0) |
119 | 124 |
|
120 | 125 | def testWebhookNotifications(self): |
|
0 commit comments