예제 #1
0
    def test1(self):
        key = "*****@*****.**"
        ent_type = "Accounts"
        trophy_case_widget = TrophyCase(key_name=key)
        points_widget = Points(key_name=key)
        rank_widget = Rank(key_name=key)
        newacc = Accounts(
            key_name=key,
            password="******",
            email=key,
            isEnabled="enabled",
            accountType="bronze",
            paymentType="free",
            cookieKey="xxx",
            apiKey="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, key)
        sameent = memcache_db.get_entity(key, ent_type)
        if sameent.email != 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.email != key:
            return "Error getting same account from DB (no cache). Subtest 2"

        # Set and get new user name
        diction = {"email": "*****@*****.**"}
        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.email != "*****@*****.**":
            return "Error getting same account after altering entity. Subtest 3"

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

        return "Success"
예제 #2
0
파일: test.py 프로젝트: gunshor/UserInfuser
    def test1(self):
        key = "*****@*****.**"
        ent_type = "Accounts"
        trophy_case_widget = TrophyCase(key_name=key)
        points_widget = Points(key_name=key)
        rank_widget = Rank(key_name=key)
        newacc = Accounts(key_name=key,
                          password="******",
                          email=key,
                          isEnabled="enabled",
                          accountType="bronze",
                          paymentType="free",
                          cookieKey="xxx",
                          apiKey="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, key)
        sameent = memcache_db.get_entity(key, ent_type)
        if sameent.email != 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.email != key:
            return "Error getting same account from DB (no cache). Subtest 2"

        # Set and get new user name
        diction = {"email": "*****@*****.**"}
        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.email != "*****@*****.**":
            return "Error getting same account after altering entity. Subtest 3"

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

        return "Success"
예제 #3
0
파일: test.py 프로젝트: gunshor/UserInfuser
    def test4(self):
        account_key = "[email protected]"
        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="******",
                          email="[email protected]",
                          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 an account
        ret = memcache_db.save_entity(newacc, account_key)

        user_key = "testuser1"
        newuser = Users(key_name=user_key,
                        userid=user_key,
                        isEnabled="yes",
                        accountRef=newacc,
                        tags=user_key)
        try:
            memcache_db.delete_entity(newacc, user_key)
        except Exception:
            pass
        # Save a user
        ret = memcache_db.save_entity(newacc, user_key)

        # Create a Badge Type
        badge_key = "testbadge1"
        badgetype = Badges(key_name=badge_key,
                           name="badge1",
                           description=badge_key,
                           altText="a really cool badge",
                           setType="free",
                           isEnabled="yes",
                           creator=newacc,
                           permissions="private",
                           storageType="blob",
                           blobKey="xxxx")
        try:
            memcache_db.delete_entity(badgetype, badge_key)
        except Exception:
            pass
        # Save and get saved ent
        ret = memcache_db.save_entity(badgetype, badge_key)

        key = "testbadgeinstance1"
        ent_type = "BadgeInstance"
        badgeinstance = BadgeInstance(key_name=key,
                                      awarded="no",
                                      badgeRef=badgetype,
                                      userRef=newuser,
                                      pointRequired=10,
                                      pointsEarned=0,
                                      permissions="private")
        try:
            memcache_db.delete_entity(badgeinstance, key)
        except Exception:
            pass
        # Save and get saved ent
        ret = memcache_db.save_entity(badgeinstance, key)
        sameent = memcache_db.get_entity(key, ent_type)
        if sameent.awarded != "no":
            return "Error getting same entity. 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.awarded != "no":
            return "Error getting same entity from DB (no cache). Subtest 2"

        # Set and get new user name
        diction = {"pointsRequired": 11, "awarded": "no"}
        inc_diction = {"pointsEarned": 5}
        ret2 = memcache_db.update_fields(key, ent_type, diction, inc_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.pointsRequired!= 11 \
              or sameent.pointsEarned != 5:
            return "Error getting same entity after altering entity. Subtest 3"

        # Cleanup
        try:
            memcache_db.delete_entity(badgeinstance, key)
        except Exception:
            return "Error deleting entity. Subtest 4"
        try:
            memcache_db.delete_entity(newacc, account_key)
        except Exception:
            return "Error deleting entity. Subtest 4"
        try:
            memcache_db.delete_entity(badgetype, badge_key)
        except Exception:
            return "Error deleting entity. Subtest 4"
        try:
            memcache_db.delete_entity(newuser, user_key)
        except Exception:
            return "Error deleting entity. Subtest 4"

        return "Success"
예제 #4
0
파일: test.py 프로젝트: gunshor/UserInfuser
    def test3(self):
        account_key = "[email protected]"
        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="******",
                          email="[email protected]",
                          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, account_key)
        except Exception:
            pass

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

        key = "testuser1"
        ent_type = "Users"
        newacc = Users(key_name=key,
                       userid=key,
                       isEnabled="yes",
                       accountRef=newacc,
                       tags=key)
        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.tags != key:
            return "Error getting same entity. 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.tags != key:
            return "Error getting same entity from DB (no cache). Subtest 2"

        # Set and get new user name
        diction = {"tags": "goodbye:hello"}
        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.tags != "goodbye:hello":
            return "Error getting same entity after altering entity. Subtest 3"

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

        return "Success"
예제 #5
0
파일: test.py 프로젝트: gunshor/UserInfuser
    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="******",
                          email="[email protected]",
                          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"
예제 #6
0
    def test4(self):
        account_key = "[email protected]"
        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="******",
            email="[email protected]",
            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 an account
        ret = memcache_db.save_entity(newacc, account_key)

        user_key = "testuser1"
        newuser = Users(key_name=user_key, userid=user_key, isEnabled="yes", accountRef=newacc, tags=user_key)
        try:
            memcache_db.delete_entity(newacc, user_key)
        except Exception:
            pass
        # Save a user
        ret = memcache_db.save_entity(newacc, user_key)

        # Create a Badge Type
        badge_key = "testbadge1"
        badgetype = Badges(
            key_name=badge_key,
            name="badge1",
            description=badge_key,
            altText="a really cool badge",
            setType="free",
            isEnabled="yes",
            creator=newacc,
            permissions="private",
            storageType="blob",
            blobKey="xxxx",
        )
        try:
            memcache_db.delete_entity(badgetype, badge_key)
        except Exception:
            pass
        # Save and get saved ent
        ret = memcache_db.save_entity(badgetype, badge_key)

        key = "testbadgeinstance1"
        ent_type = "BadgeInstance"
        badgeinstance = BadgeInstance(
            key_name=key,
            awarded="no",
            badgeRef=badgetype,
            userRef=newuser,
            pointRequired=10,
            pointsEarned=0,
            permissions="private",
        )
        try:
            memcache_db.delete_entity(badgeinstance, key)
        except Exception:
            pass
        # Save and get saved ent
        ret = memcache_db.save_entity(badgeinstance, key)
        sameent = memcache_db.get_entity(key, ent_type)
        if sameent.awarded != "no":
            return "Error getting same entity. 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.awarded != "no":
            return "Error getting same entity from DB (no cache). Subtest 2"

        # Set and get new user name
        diction = {"pointsRequired": 11, "awarded": "no"}
        inc_diction = {"pointsEarned": 5}
        ret2 = memcache_db.update_fields(key, ent_type, diction, inc_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.pointsRequired != 11 or sameent.pointsEarned != 5:
            return "Error getting same entity after altering entity. Subtest 3"

        # Cleanup
        try:
            memcache_db.delete_entity(badgeinstance, key)
        except Exception:
            return "Error deleting entity. Subtest 4"
        try:
            memcache_db.delete_entity(newacc, account_key)
        except Exception:
            return "Error deleting entity. Subtest 4"
        try:
            memcache_db.delete_entity(badgetype, badge_key)
        except Exception:
            return "Error deleting entity. Subtest 4"
        try:
            memcache_db.delete_entity(newuser, user_key)
        except Exception:
            return "Error deleting entity. Subtest 4"

        return "Success"
예제 #7
0
    def test3(self):
        account_key = "[email protected]"
        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="******",
            email="[email protected]",
            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, account_key)
        except Exception:
            pass

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

        key = "testuser1"
        ent_type = "Users"
        newacc = Users(key_name=key, userid=key, isEnabled="yes", accountRef=newacc, tags=key)
        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.tags != key:
            return "Error getting same entity. 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.tags != key:
            return "Error getting same entity from DB (no cache). Subtest 2"

        # Set and get new user name
        diction = {"tags": "goodbye:hello"}
        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.tags != "goodbye:hello":
            return "Error getting same entity after altering entity. Subtest 3"

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

        return "Success"
예제 #8
0
    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="******",
            email="[email protected]",
            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"