Skip to content

Commit

Permalink
tests for recipients api flake8 geopython#15
Browse files Browse the repository at this point in the history
  • Loading branch information
cezio committed Feb 15, 2018
1 parent 449c6e4 commit 47b99ed
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions tests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import sys
import os
from GeoHealthCheck.models import (DB, Resource, Run, load_data,
ResourceNotification, Recipient)
Recipient)
from GeoHealthCheck.healthcheck import run_test_resource

TEST_DIR = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -88,8 +88,6 @@ def testRunResoures(self):
(resource.url, str(resource.runs[0])))

def testNotificationsApi(self):
R = Resource
RN = ResourceNotification
Rcp = Recipient
test_emails = ['test@test.com', 'other@test.com', 'unused@test.com']
invalid_emails = ['invalid', None, object()]
Expand All @@ -103,16 +101,15 @@ def testNotificationsApi(self):
Rcp.get_or_create('email', email)
from_db = set(r[0] for r in DB.session.query(Rcp.location).all())
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 = Rcp.query.filter(Rcp.location == test_emails[-1])
self.assertEqual(q.count(), 0)



if __name__ == '__main__':
unittest.main()

0 comments on commit 47b99ed

Please sign in to comment.