Пример #1
0
def test_Enqueue_NoCommand_TaskNotQueued():
    c = command.CommandManager()
    c._submitTask = Mock()

    c.Enqueue("func", ())

    c._submitTask.assert_not_called()
Пример #2
0
def test_AddCommand_OverwritesExisting():
    c = command.CommandManager()
    c._Catalog = {"my_alias": lambda y: y}
    f = lambda x: x
    c.Add('my_alias', f)

    assert c._Catalog["my_alias"] == f
Пример #3
0
def test_Enqueue_CallsTaskEnqueueFunc():
    c = command.CommandManager()
    f = lambda x: x
    c._Catalog = {"func": f}
    a = ('a', 'b')
    c._submitTask = Mock()

    c.Enqueue("func", a)

    c._submitTask.assert_called_once_with(f, a)
Пример #4
0
    def __init__(self):
        import datetime
        self.id = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        self.g = graphics.Graphics(53, 30)
        self.r = graphics.Renderer(self.g)
        self.s = screens.ScreenManager(self.r)
        self.c = command.CommandManager()
        self.a = animation.AnimationPlayer(self)
        self.variables = {}  #state:(animation,location,intro)
        self.date = None

        self.player = None

        self.running = False
Пример #5
0
import asyncio

import util
import command
import constants

from mpmath import mp
import sympy
from sympy.parsing import sympy_parser
import discord
from discord.ext import commands

# configure mpmath
mp.dps = constants.DEFAULT_PRECISION

cm = command.CommandManager()


@cm.has_commands
class CoffeeBot(commands.Bot):
    '''The math bot'''
    def __init__(self):
        super().__init__(command_prefix='$',
                         description='A math bot written in Python')
        self.__config_commands()
        self.channel = None
        self.testing = util.read_testing()
        self.xp = util.read_xp()

    def __config_commands(self):
        self.remove_command('help')  # remove default help command
Пример #6
0
def test_Add():
    c = command.CommandManager()
    f = lambda x: x
    c.Add('my_alias', f)

    assert c._Catalog["my_alias"] == f
Пример #7
0
def test_CommandManager_constructor():
    c = command.CommandManager()

    assert c is not None
    assert c._Catalog == {}
Пример #8
0
def test_GetCommandFn_CommandNotExist():
    c = command.CommandManager()
    assert c.GetCommandFn('a') is None
Пример #9
0
def test_GetCommandFn_CommandExists():
    c = command.CommandManager()
    f = lambda x: x
    c._Catalog = {'a': f}

    assert c.GetCommandFn('a') == f
Пример #10
0
def test_SetSubmitTaskFn():
    c = command.CommandManager()
    f = lambda x: x
    c.SetSubmitTaskFn(f)

    assert c._submitTask == f
Пример #11
0
def test_IsCommand_CommandNotAvailable():
    c = command.CommandManager()
    c._Catalog = {'myCommand': lambda x: x}

    assert not c.IsCommand('dummy_command')
Пример #12
0
def test_IsCommand_NoCommands():
    c = command.CommandManager()

    assert not c.IsCommand('dummy_command')
Пример #13
0
    def execute_commands(self, monitor):
        self.check_modified()

        proc_list = [x.command for x in self.command_ui_list]
        cm = cmd.CommandManager()
        cm.execute_commands(proc_list, monitor=monitor)