예제 #1
0
    def test_non_existing_plugin(self):
        slack = Slack(token='spam_ham_egg',
                      plugins=(('spam.ham.egg.onion', {}),),
                      max_workers=1)
        slack.load_plugins()

        assert_that(slack.commands).is_empty()
        assert_that(slack.scheduler.get_jobs()).is_empty()
예제 #2
0
    def test_load_plugins(self):
        slack = Slack(token='spam_ham_egg',
                      plugins=(('sarah.bot.plugins.simple_counter', {}),
                               ('sarah.bot.plugins.echo', {})),
                      max_workers=1)
        slack.load_plugins()

        assert_that(slack.commands) \
            .described_as("3 commands are loaded") \
            .is_length(3) \
            .extract('name') \
            .contains('.count',
                      '.reset_count',
                      '.echo')

        assert_that(slack.commands) \
            .extract('name', 'module_name') \
            .contains_sequence(('.count', 'sarah.bot.plugins.simple_counter'),
                               ('.reset_count',
                                'sarah.bot.plugins.simple_counter'),
                               ('.echo', 'sarah.bot.plugins.echo'))

        for command in slack.commands:
            assert_that(command.function).is_type_of(types.FunctionType)