Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Return only valid team members from lookup.json
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Aug 3, 2016
1 parent 505c14f commit 51d9739
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/py/test_lookup_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ def lookup(self, q):
data = json.loads(response.body)
return [d['id'] for d in data]


def make_alice(self, **kw):
kw.update(claimed_time='now', email_address='[email protected]', verified_in='TT')
return self.make_participant("alice", **kw)

def test_get_without_query_returns_400(self):
response = self.client.GxT('/lookup.json')
assert response.code == 400
Expand All @@ -19,19 +24,19 @@ def test_looking_up_non_existent_user_finds_nothing(self):
assert self.lookup('alice') == [-1]

def test_looking_up_non_searchable_user_with_an_exact_match_finds_them(self):
alice = self.make_participant("alice", claimed_time='now', is_searchable=False)
alice = self.make_alice(is_searchable=False)
assert self.lookup('alice') == [alice.id]

def test_looking_up_non_searchable_user_without_exact_match_finds_nothing(self):
self.make_participant("alice", claimed_time='now', is_searchable=False)
self.make_alice(is_searchable=False)
assert self.lookup('alic') == [-1]

def test_looking_up_searchable_user_with_an_exact_match_finds_them(self):
alice = self.make_participant("alice", claimed_time='now')
alice = self.make_alice()
assert self.lookup('alice') == [alice.id]

def test_looking_up_searchable_user_without_an_exact_match_finds_them(self):
alice = self.make_participant("alice", claimed_time='now')
alice = self.make_alice()
assert self.lookup('alic') == [alice.id, -1]


Expand All @@ -42,16 +47,16 @@ def test_looking_up_suspicious_user_finds_nothing(self):
, email_address='[email protected]'
, is_suspicious=True
)
assert self.lookup('alice') == []
assert self.lookup('alice') == [-1]

def test_looking_up_unverified_user_finds_nothing(self):
self.make_participant("alice", claimed_time='now', email_address='[email protected]')
assert self.lookup('alice') == []
assert self.lookup('alice') == [-1]

def test_looking_up_user_with_no_email_finds_nothing(self):
self.make_participant("alice", claimed_time='now') # can't verify w/o email!
assert self.lookup('alice') == []
assert self.lookup('alice') == [-1]

def test_looking_up_unclaimed_user_finds_nothing(self):
self.make_participant("alice", verified_in='TT', email_address='[email protected]')
assert self.lookup('alice') == []
assert self.lookup('alice') == [-1]
4 changes: 4 additions & 0 deletions www/lookup.json.spt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ SQL = """
AND
is_suspicious IS NOT TRUE
AND
email_address IS NOT NULL
AND
has_verified_identity
AND
(
(is_searchable AND username_lower LIKE %s)
OR
Expand Down

0 comments on commit 51d9739

Please sign in to comment.