def testListAll(self): ghost_one = Ghost(ghost_name="Tom") ghost_two = Ghost(ghost_name="Dick") ghost_three = Ghost(ghost_name="Harry") ndb.put_multi([ghost_one, ghost_two, ghost_three]) result = GhostrEngine.list_all() assert result.count() == 3
def testListRandomThree(self): user = users.User("*****@*****.**") ghost_one = Ghost(ghost_name="Tom", gmail=user) ghost_two = Ghost(ghost_name="Dick") ghost_three = Ghost(ghost_name="Harry") ndb.put_multi([ghost_one, ghost_two, ghost_three]) available_ghosts = GhostrEngine.list_random_three() assert "Harry" in available_ghosts assert "Dick" in available_ghosts assert "Tom" not in available_ghosts
def testClearUserData(self): user = users.User("*****@*****.**") first_name = "Master" second_name = "Roshi" ghost_name = "Babadook" ghost = Ghost( gmail=user, first_name=first_name, second_name=second_name, ghost_name=ghost_name) ghost.put() stored_ghost = Ghost.query().get() assert stored_ghost.gmail == user assert stored_ghost.first_name == first_name assert stored_ghost.second_name == second_name assert stored_ghost.ghost_name == ghost_name GhostrEngine.clear_user_data(stored_ghost) updated_stored_ghost = Ghost.query().get() assert updated_stored_ghost.gmail is None assert updated_stored_ghost.first_name is None assert updated_stored_ghost.second_name is None
def testGetFromUser(self): user = users.User("*****@*****.**") ghost = Ghost(gmail=user) ghost.put() assert GhostrEngine.get_from_user(user) == ghost assert GhostrEngine.get_from_user(None) is None
def testSetFormText(self): user_one = users.User("*****@*****.**") user_two = users.User("*****@*****.**") ghost = Ghost(gmail=user_one).put() assert GhostrEngine.set_form_text( user_one) == "Change your current Phantom name" assert GhostrEngine.set_form_text(user_two) == "Get a Phantom name"
def testGhostProperties(self): user = users.User("*****@*****.**") first_name = "Master" second_name = "Roshi" ghost_name = "Babadook" ghost = Ghost( gmail=user, first_name=first_name, second_name=second_name, ghost_name=ghost_name) ghost.put() stored_ghost = Ghost.query().get() self.assertEqual(user, stored_ghost.gmail) self.assertEqual(first_name, stored_ghost.first_name) self.assertEqual(second_name, stored_ghost.second_name) self.assertEqual(ghost_name, stored_ghost.ghost_name)
def testInsertEntity(self): Ghost().put() self.assertEqual(1, len(Ghost.query().fetch(2)))
def testGetFromGhostname(self): ghost = Ghost(ghost_name="Tom") ghost.put() assert GhostrEngine.get_from_ghostname("Tom") == ghost