def test_login_multiple_matches(self): """Earliest created is preferred.""" email = '*****@*****.**' password = '******' user1 = User.create(email=email) user1.hashed_password = User.hash_password(password) user1.put() # We'll have to hack around our protections against this sort of thing # so we can test what will happen if the protections fail. Unique.query().get().key.delete() # Create the user we'll login as. user2 = User.create(email=email) user2.hashed_password = User.hash_password(password) user2.put() response = self.testapp.post_json('/api/login', { 'auth_type': 'email', 'email': email, 'password': password }) response_user = json.loads(response.body) self.assertEqual(response_user['uid'], user1.uid)
def test_create_code_creates_unique(self): """Should be an entry in Unique to ensure unique code.""" user = User.create(email='*****@*****.**') user.put() response = self.testapp.post_json( '/api/codes', {'organization_id': 'triton', 'program_label': 'triton'}, headers=self.login_headers(user) ) pc = ProjectCohort.query().fetch(1) unique = Unique.query().fetch(1) self.assertIsNotNone(pc) self.assertIsNotNone(unique)