diff --git a/tests/py/test_lookup_json.py b/tests/py/test_lookup_json.py index 35fe290a91..89f43a3e3e 100644 --- a/tests/py/test_lookup_json.py +++ b/tests/py/test_lookup_json.py @@ -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='alice@example.com', 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 @@ -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] @@ -42,16 +47,16 @@ def test_looking_up_suspicious_user_finds_nothing(self): , email_address='alice@example.com' , 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='alice@example.com') - 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='alice@example.com') - assert self.lookup('alice') == [] + assert self.lookup('alice') == [-1] diff --git a/www/lookup.json.spt b/www/lookup.json.spt index ea3b3ba5f2..b5abc21330 100644 --- a/www/lookup.json.spt +++ b/www/lookup.json.spt @@ -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