Esempio n. 1
0
        def test_on_episodes(*args, **kwargs):
            episodes = Registry.get_available_episodes()

            for episode in episodes:
                if episode in skip:
                    continue

                # Load the next episode.
                Registry.set_current_episode(episode)
                Registry.load_current_episode()

                try:
                    # Call the test method.
                    function(*args, **kwargs)
                except Exception:
                    # Inform about which episode failed and propagate the failure.
                    print('Failed test in episode "{}"'.format(episode))
                    raise
Esempio n. 2
0
 def step_begin(self):
     self.wait_confirm('HELLO1')
     action = self.show_choices_message(
         'HELLO2', ('NOQUEST_POSITIVE', None, True),
         ('NOQUEST_NEGATIVE', None, False)).wait()
     if action.future.result():
         registry = Registry.get_or_create()
         registry.schedule_quest('Snow', **self.__auto_offer_info__)
         return self.step_complete_and_stop
     else:
         return self.step_abort
Esempio n. 3
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(), '')
Esempio n. 4
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)
Esempio n. 5
0
    def test_empty_message_with_active_questsets(self):
        """Tests the QuestSets empty messages when other QuestSet objects are active."""
        quest_sets = Registry.get_quest_sets()
        quest_sets_to_test = []

        for quest_set in quest_sets:
            # Skip checking the Trap quest set here as it's different.
            if str(quest_set) == 'TrapQuestSet':
                continue

            self.deactivate_quest_set(quest_set)
            quest_sets_to_test.append(quest_set)

        for quest_set in quest_sets_to_test:
            self.check_empty_message_with_active_questsets(
                quest_sets_to_test, quest_set)
Esempio n. 6
0
    def test_load_mixed_quest_definitions(self):
        '''Tests loading a QuestSet with quests defined as strings and as classes.'''
        quest_set_source = '''
from phonyep.aquest import AQuest
from eosclubhouse.libquest import Registry, QuestSet

class TestQuestSet(QuestSet):
    __pathway_name__ = 'web'
    __character_id__ = 'phony'
    __quests__ = [AQuest, 'ZQuest']

Registry.register_quest_set(TestQuestSet)
'''
        quest_source_template = '''
from eosclubhouse.libquest import Quest
class {}(Quest):
    pass
'''

        with tempfile.TemporaryDirectory() as tmpdir:
            episode_name = 'phonyep'
            dir_name = os.path.join(tmpdir, episode_name)
            os.mkdir(dir_name)

            quest_names = ['AQuest', 'ZQuest']
            for name in quest_names:
                with open(os.path.join(dir_name,
                                       name.lower() + '.py'),
                          'w') as quest_set_file:
                    quest_set_file.write(quest_source_template.format(name))

            # Set the quests for the QuestSet, the first is given as a string, the second as a
            # symbol.
            with open(os.path.join(dir_name, 'testquestset.py'),
                      'w') as quest_set_file:
                quest_set_file.write(quest_set_source)

            Registry._reset()
            Registry._loaded_episode = episode_name
            Registry.load(dir_name)
            self.assertIn('TestQuestSet', [
                quest_set.get_id() for quest_set in Registry.get_quest_sets()
            ])
Esempio n. 7
0
 def setUp(self):
     Registry.load_current_episode()
Esempio n. 8
0
#
# Copyright © 2020 Endless OS Foundation LLC.
#
# This file is part of clubhouse
# (see https://github.com/endlessm/clubhouse).
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from eosclubhouse.libquest import QuestSet, Registry


class MakerPathWay(QuestSet):

    __pathway_name__ = 'Maker'
    __character_id__ = 'faber'


Registry.register_quest_set(MakerPathWay)
Esempio n. 9
0
 def test_default_episode(self):
     Registry.load_current_episode()
     self.assertEqual(Registry.get_loaded_episode_name(),
                      config.DEFAULT_EPISODE_NAME)
Esempio n. 10
0
#
# Copyright © 2020 Endless OS Foundation LLC.
#
# This file is part of clubhouse
# (see https://github.com/endlessm/clubhouse).
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from eosclubhouse.libquest import QuestSet, Registry


class ArtPathWay(QuestSet):

    __pathway_name__ = 'Art'
    __character_id__ = 'estelle'


Registry.register_quest_set(ArtPathWay)
Esempio n. 11
0
def setup_episode(quest_set_list, episode_name='tests-phony-episode'):
    Registry._reset()
    Registry._quest_sets = quest_set_list
    Registry._loaded_episode = episode_name
Esempio n. 12
0
#
# Copyright © 2020 Endless OS Foundation LLC.
#
# This file is part of clubhouse
# (see https://github.com/endlessm/clubhouse).
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from eosclubhouse.libquest import QuestSet, Registry


class OSPathWay(QuestSet):

    __pathway_name__ = 'Operating System'
    __character_id__ = 'saniel'


Registry.register_quest_set(OSPathWay)
Esempio n. 13
0
#
# Copyright © 2020 Endless OS Foundation LLC.
#
# This file is part of clubhouse
# (see https://github.com/endlessm/clubhouse).
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from eosclubhouse.libquest import QuestSet, Registry


class WebPathWay(QuestSet):

    __pathway_name__ = 'Web'
    __character_id__ = 'riley'


Registry.register_quest_set(WebPathWay)
Esempio n. 14
0
 def test_questset_contents(self):
     """Tests if any QuestSets are loaded."""
     quest_sets = Registry.get_quest_sets()
     self.assertGreater(len(quest_sets), 0)
Esempio n. 15
0
 def setUp(self):
     self.reset_gss()
     Registry.load_current_episode()
Esempio n. 16
0
#
# Copyright © 2020 Endless OS Foundation LLC.
#
# This file is part of clubhouse
# (see https://github.com/endlessm/clubhouse).
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from eosclubhouse.libquest import QuestSet, Registry


class GamesPathWay(QuestSet):

    __pathway_name__ = 'Games'
    __character_id__ = 'ada'


Registry.register_quest_set(GamesPathWay)