Exemple #1
0
    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
Exemple #2
0
    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
Exemple #3
0
    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
Exemple #4
0
    def testSetup(self):
        test_names = ["Tom", "Dick", "Harry"]
        GhostrEngine.setup(test_names)

        stored_ghosts = Ghost.query()

        for ghost in stored_ghosts:
            assert ghost.ghost_name in test_names
Exemple #5
0
    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"
Exemple #6
0
    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)
Exemple #7
0
    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
Exemple #8
0
 def testInsertEntity(self):
     Ghost().put()
     self.assertEqual(1, len(Ghost.query().fetch(2)))
Exemple #9
0
    def testGetFromGhostname(self):
        ghost = Ghost(ghost_name="Tom")
        ghost.put()

        assert GhostrEngine.get_from_ghostname("Tom") == ghost