示例#1
0
def omlet_bite_test(self):
    test_username = self.user.name
    self.write('<br>username is: ' + test_username)
    user = User.by_name(test_username)
    self.write('<br>user.id() is: ' + str(user.key().id()))

    # # FOR DELETING
    # delete_for_user(self, test_username)

    omlet1 = Omlet.make_omlet(test_username, 'first')
    if omlet1:
        omlet1.put()
    time.sleep(0.5)
    self.write('<br><br>put in omlet called "first" ')
    self.write('<br>list of omlets for this user is ' + string_list_omlet(Omlet.list_username(test_username)))
    self.write('<br>look, the omlet exists: ' + string_omlet(Omlet.by_name('first')))

    self.write('<br><br>this should be empty: ' + string_list_bite(Bite.list_omlet_until_number('first', None)))
    make_bite_noduplicate('first', 'Bite AAAAA')
    time.sleep(0.5)
    make_bite_noduplicate('first', 'This is bite B of omlet1')
    time.sleep(0.5)
    self.write('<br>this should have two bites: ' + string_list_bite(Bite.list_omlet_until_number('first', None)))

    make_bite_noduplicate('first', 'Bite C')
    time.sleep(0.5)
    make_bite_noduplicate('first', 'Bite D, yay')
    time.sleep(0.5)
    make_bite_noduplicate('first', 'Nom, Bite E')
    time.sleep(0.5)
    self.write('<br><br> want up to bite C: ' + string_list_bite(Bite.list_omlet_until_number('first', 3)))
    self.write('<br> want bite D only: ' + string_bite(Bite.by_omlet_number('first', 4)))

    Bite.set_eaten('first', 2)
    time.sleep(0.5)
    self.write('<br>has bite B been eaten? should be yes: ' + string_bite(Bite.by_omlet_number('first', 2)))

    omlet2 = Omlet.make_omlet(test_username, 'second')
    if omlet2:
        omlet2.put()
    time.sleep(0.5)
    omlet3 = Omlet.make_omlet(test_username, 'third')
    if omlet3:
        omlet3.put()
    time.sleep(0.5)
    omlet4 = Omlet.make_omlet(test_username, 'fourth')
    if omlet4:
        omlet4.put()
    time.sleep(0.5)
    self.write('<br><br>list of omlets for this user should have 4: ' + string_list_omlet(Omlet.list_username(test_username)))
示例#2
0
    def my_txn():
        test_username = self.user.name
        self.write('<br>username is: ' + test_username)
        print('username is: ' + test_username)
        user = User.by_name(test_username)
        self.write('<br>user.id() is: ' + str(user.key().id()))
        print('user.id() is: ' + str(user.key().id()))

        # FOR DELETING
        delete_for_user(self, test_username)

        omlet1 = Omlet.make_omlet(test_username, 'amy1')
        print('omletparent', omlet1.parent().key().id());
        print('user', user.key().id())
        print('omlet:' + omlet1.name)
        key1 = omlet1.put()
        print('omlet1 newkey:', key1.id())
        omlet2 = Omlet.get_by_id(key1.id(),
            parent = user,
            read_policy = db.STRONG_CONSISTENCY)
        print('omlet2: ' + omlet2.name)
        self.write('<br><br>put in omlet called "amy1" ')
        self.write('<br>list of omlets for this user is ' + string_list_omlet(Omlet.list_username(test_username)))
        self.write('<br>look, the omlet exists: ' + string_omlet(Omlet.by_name('amy1')))

        self.write('<br><br>this should be empty: ' + string_list_bite(Bite.list_omlet_until_number('amy1', None)))
        make_bite_noduplicate('amy1', 'Bite AAAAA')
        make_bite_noduplicate('amy1', 'This is bite B of omlet1')
        self.write('<br>this should have two bites: ' + string_list_bite(Bite.list_omlet_until_number('amy1', None)))

        make_bite_noduplicate('amy1', 'Bite C')
        make_bite_noduplicate('amy1', 'Bite D, yay')
        make_bite_noduplicate('amy1', 'Nom, Bite E')
        self.write('<br><br> want up to bite C: ' + string_list_bite(Bite.list_omlet_until_number('amy1', 3)))
        self.write('<br> want bite D only: ' + string_bite(Bite.by_omlet_number('amy1', 4)))
示例#3
0
def my_txn():
    test_username = self.user.name
    self.write('<br>username is: ' + test_username)
    user = User.by_name(test_username)
    self.write('<br>user.id() is: ' + str(user.key().id()))

    # FOR DELETING
    delete_for_user(self, test_username)

    omlet1 = Omlet.make_omlet(test_username, 'amy1')
    if omlet1:
        omlet1.put()
    self.write('<br><br>put in omlet called "amy1" ')
    self.write('<br>list of omlets for this user is ' + string_list_omlet(Omlet.list_username(test_username)))
    self.write('<br>look, the omlet exists: ' + string_omlet(Omlet.by_name('amy1')))

    self.write('<br><br>this should be empty: ' + string_list_bite(Bite.list_omlet_until_number('amy1', None)))
    make_bite_noduplicate('amy1', 'Bite AAAAA')
    make_bite_noduplicate('amy1', 'This is bite B of omlet1')
    self.write('<br>this should have two bites: ' + string_list_bite(Bite.list_omlet_until_number('amy1', None)))

    make_bite_noduplicate('amy1', 'Bite C')
    make_bite_noduplicate('amy1', 'Bite D, yay')
    make_bite_noduplicate('amy1', 'Nom, Bite E')
    self.write('<br><br> want up to bite C: ' + string_list_bite(Bite.list_omlet_until_number('amy1', 3)))
    self.write('<br> want bite D only: ' + string_bite(Bite.by_omlet_number('amy1', 4)))