Ejemplo n.º 1
0
    def testOptOut(self):
        """Test that once a user opts out of a quest, it doesn't show up."""
        quest = Quest(
            name="Another quest",
            quest_slug="another_quest",
            description="another quest",
            priority=1,
            unlock_conditions="False",  # User cannot unlock this quest
            completion_conditions="False",
        )
        quest.save()

        self.assertFalse(quest.opt_out(self.user),
                         "User should not be able to see this quest.")

        quest.unlock_conditions = "True"
        quest.save()
        self.assertTrue(quest.opt_out(self.user),
                        "User should be able to opt out of this quest.")

        quests = get_quests(self.user)
        self.assertTrue(quest not in quests["available_quests"],
                        "User should not see the quest as available.")
        self.assertTrue(
            quest not in quests["user_quests"],
            "User should not have this listed as their current quest.")
Ejemplo n.º 2
0
    def testAccept(self):
        """Test that the user can accept quests."""
        quest = Quest(
            name="Another quest",
            quest_slug="another_quest",
            description="another quest",
            level=1,
            unlock_conditions="False",  # User cannot unlock this quest
            completion_conditions="False",
        )
        quest.save()

        self.assertFalse(quest.accept(self.user), "User should not be able to accept this quest.")
        self.assertEqual(self.user.quest_set.count(), 0, "User should not have any quests.")

        quest.unlock_conditions = "True"
        quest.save()
        self.assertTrue(quest.accept(self.user), "User should be able to accept this quest.")
        self.assertEqual(self.user.quest_set.count(), 1, "User should have an accepted quest.")
Ejemplo n.º 3
0
    def testOptOut(self):
        """Test that once a user opts out of a quest, it doesn't show up."""
        quest = Quest(
            name="Another quest",
            quest_slug="another_quest",
            description="another quest",
            level=1,
            unlock_conditions="False",  # User cannot unlock this quest
            completion_conditions="False",
        )
        quest.save()

        self.assertFalse(quest.opt_out(self.user), "User should not be able to see this quest.")

        quest.unlock_conditions = "True"
        quest.save()
        self.assertTrue(quest.opt_out(self.user), "User should be able to opt out of this quest.")

        quests = get_quests(self.user)
        self.assertTrue(quest not in quests["available_quests"],
            "User should not see the quest as available.")
        self.assertTrue(quest not in quests["user_quests"],
            "User should not have this listed as their current quest.")
Ejemplo n.º 4
0
    def testAccept(self):
        """Test that the user can accept quests."""
        quest = Quest(
            name="Another quest",
            quest_slug="another_quest",
            description="another quest",
            priority=1,
            unlock_conditions="False",  # User cannot unlock this quest
            completion_conditions="False",
        )
        quest.save()

        self.assertFalse(quest.accept(self.user),
                         "User should not be able to accept this quest.")
        self.assertEqual(self.user.quest_set.count(), 0,
                         "User should not have any quests.")

        quest.unlock_conditions = "True"
        quest.save()
        self.assertTrue(quest.accept(self.user),
                        "User should be able to accept this quest.")
        self.assertEqual(self.user.quest_set.count(), 1,
                         "User should have an accepted quest.")