def testForNonLoggedInAccount(self): """Tests that user is not created when no account is logged in.""" # make sure that nobody is logged in profile_utils.logout() result = ndb.transaction(lambda: user_logic.createUser(TEST_USERNAME)) self.assertFalse(result)
def testUserExists(self): """Tests that user entity is not existed for a taken username.""" # seed a user with a specific username profile_utils.seedNDBUser(user_id=TEST_USERNAME) # sign in a user with an account but with no user entity profile_utils.signInToGoogleAccount(TEST_EMAIL, TEST_ACCOUNT_ID) result = ndb.transaction(lambda: user_logic.createUser(TEST_USERNAME)) self.assertFalse(result)
def testUserCreated(self): """Tests that user entity is created.""" program = program_utils.seedProgram() # sign in a user with an account but with no user entity profile_utils.signInToGoogleAccount(TEST_EMAIL, TEST_ACCOUNT_ID) result = ndb.transaction(lambda: user_logic.createUser( TEST_USERNAME, host_for=[ndb.Key.from_old_key(program.key())])) self.assertTrue(result) self.assertEqual(result.extra.key.id(), TEST_USERNAME) self.assertEqual(result.extra.account_id, TEST_ACCOUNT_ID) self.assertIn(ndb.Key.from_old_key(program.key()), result.extra.host_for)
def testUserCreated(self): """Tests that user entity is created.""" program = program_utils.seedProgram() # sign in a user with an account but with no user entity profile_utils.signInToGoogleAccount(TEST_EMAIL, TEST_ACCOUNT_ID) result = ndb.transaction( lambda: user_logic.createUser( TEST_USERNAME, host_for=[ndb.Key.from_old_key(program.key())])) self.assertTrue(result) self.assertEqual(result.extra.key.id(), TEST_USERNAME) self.assertEqual(result.extra.account_id, TEST_ACCOUNT_ID) self.assertIn( ndb.Key.from_old_key(program.key()), result.extra.host_for)