示例#1
0
  def testForLoggedInAccountWithNoUserEntity(self):
    """Tests that None is returned for a logged-in user with no entity."""
    # sign in a user with an account but with no user entity
    profile_utils.signInToGoogleAccount(TEST_EMAIL, TEST_ACCOUNT_ID)

    result = user_logic.getByCurrentAccount()
    self.assertIsNone(result)
示例#2
0
    def testForLoggedInAccountWithNoUserEntity(self):
        """Tests that None is returned for a logged-in user with no entity."""
        # sign in a user with an account but with no user entity
        profile_utils.signInToGoogleAccount(TEST_EMAIL, TEST_ACCOUNT_ID)

        result = user_logic.getByCurrentAccount()
        self.assertIsNone(result)
示例#3
0
  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)
示例#4
0
    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)
示例#5
0
    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)
示例#6
0
  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)