def test2(self):
    account_key = "raj"
    trophy_case_widget = TrophyCase(key_name=account_key)
    points_widget = Points(key_name=account_key)
    rank_widget = Rank(key_name=account_key)
    newacc = Accounts(key_name=account_key,
                     password="aaa",
                     email="a@a.a",
                     isEnabled="enabled",
                     accountType="bronze",
                     paymentType="free",
                     apiKey="xxx",
                     cookieKey="xxx",
                     trophyWidget=trophy_case_widget,
                     pointsWidget=points_widget,
                     rankWidget=rank_widget)
    try:
      memcache_db.delete_entity(newacc, key)
    except Exception:
      pass

    # Save and get saved ent
    ret = memcache_db.save_entity(newacc, account_key)

    key = "testbadge1"
    ent_type = "Badges"
    newacc = Badges(key_name=key, 
                    name="badge1",
                    description=key,
                    altText="a really cool badge", 
                    setType="free",
                    isEnabled="yes",
                    creator=newacc,
                    permissions="private",
                    blobKey="xxxx",
                    storageType="blob") 
    try:
      memcache_db.delete_entity(newacc, key)
    except Exception:
      pass
    # Save and get saved ent
    ret = memcache_db.save_entity(newacc, key)
    sameent = memcache_db.get_entity(key, ent_type)
    if sameent.description != key:
      return "Error getting same account. Subtest 1"

    # purge from memcache and get from db
    memcache.delete(key=key, namespace=ent_type)
    sameent = memcache_db.get_entity(key, ent_type)
    if sameent.description != key:
      return "Error getting same account from DB (no cache). Subtest 2"

    # Set and get new user name
    diction = {"isEnabled":"no", "permissions":"public"}
    ret2 = memcache_db.update_fields(key, ent_type, diction)
    ret2 = sameent.put()
    if ret != ret2:
      self.response.out.write("Error getting key name")
    sameent = memcache_db.get_entity(key, ent_type)
    if sameent.isEnabled != "no" or sameent.permissions != "public":
      return "Error getting same account after altering entity. Subtest 3"

    try:
      memcache_db.delete_entity(sameent, key)
    except Exception:
      return "Error deleting entity. Subtest 4"

    try:
      memcache_db.delete_entity(newacc, account_key)
    except Exception:
      return "Error deleting account. Subtest 5"

    return "Success"