Beispiel #1
0
    def test_default_main_character(self):
        '''Tests there is some default main character when not provided in the catalog.'''
        QuestA = define_quest('QuestA')

        PhonyAlice = define_questset('PhonyAlice', 'web', 'alice')
        PhonyAlice.__quests__ = [QuestA]

        setup_episode([PhonyAlice()])

        quest_a = Registry.get_quest_by_name('QuestA')
        self.assertEqual(quest_a.get_main_character(), 'alice')
        self.assertNotEqual(quest_a.get_main_character(), '')
Beispiel #2
0
    def test_available(self):
        '''Tests quest availability flags.'''
        QuestA = define_quest('QuestAvailable')

        PhonyAlice = define_questset('PhonyAlice', 'web', 'alice')
        PhonyAlice.__quests__ = [QuestA]

        setup_episode([PhonyAlice()])

        quest_a = Registry.get_quest_by_name('QuestAvailable')
        self.assertEqual(quest_a.available, True)

        today = datetime.datetime.now()
        yesterday = today - datetime.timedelta(days=1)
        tomorrow = today + datetime.timedelta(days=1)
        tomorrow1 = today + datetime.timedelta(days=2)

        # Testing available_since
        quest_a.available_until = ''
        quest_a.available_since = tomorrow.strftime('%Y-%m-%d')
        self.assertEqual(quest_a.available, False)
        quest_a.available_since = yesterday.strftime('%Y-%m-%d')
        self.assertEqual(quest_a.available, True)

        # Testing available_until
        quest_a.available_since = ''
        quest_a.available_until = yesterday.strftime('%Y-%m-%d')
        self.assertEqual(quest_a.available, False)
        quest_a.available_until = tomorrow.strftime('%Y-%m-%d')
        self.assertEqual(quest_a.available, True)

        # Testing available_since and available_until
        quest_a.available_since = yesterday.strftime('%Y-%m-%d')
        quest_a.available_until = yesterday.strftime('%Y-%m-%d')
        self.assertEqual(quest_a.available, False)

        quest_a.available_since = yesterday.strftime('%Y-%m-%d')
        quest_a.available_until = tomorrow.strftime('%Y-%m-%d')
        self.assertEqual(quest_a.available, True)

        quest_a.available_since = today.strftime('%Y-%m-%d')
        quest_a.available_until = tomorrow.strftime('%Y-%m-%d')
        self.assertEqual(quest_a.available, True)

        quest_a.available_since = today.strftime('%Y-%m-%d')
        quest_a.available_until = today.strftime('%Y-%m-%d')
        self.assertEqual(quest_a.available, True)

        quest_a.available_since = tomorrow.strftime('%Y-%m-%d')
        quest_a.available_until = tomorrow1.strftime('%Y-%m-%d')
        self.assertEqual(quest_a.available, False)