コード例 #1
0
ファイル: test_cli.py プロジェクト: demas/stackify
def test_equal_command():
    func = mock.MagicMock()
    c = Command(command_type=CommandType.EQUAL, value="a", action=func)
    parser = Parser()
    parser.add_command(c)

    parser.process_message("a")

    assert func.called
コード例 #2
0
ファイル: test_cli.py プロジェクト: demas/stackify
def test_start_with_command_not_ke(message):
    func = mock.MagicMock()
    c = Command(command_type=CommandType.START_WITH, value="foo", action=func)
    parser = Parser()
    parser.add_command(c)

    parser.process_message(message)

    assert not func.called
コード例 #3
0
ファイル: test_cli.py プロジェクト: demas/stackify
def test_in_list_command_not_ok(message):
    func = mock.MagicMock()
    c = Command(command_type=CommandType.IN_LIST,
                value=["a", "b", "c"],
                action=func)
    parser = Parser()
    parser.add_command(c)

    parser.process_message(message)

    assert not func.called
コード例 #4
0
ファイル: test_cli.py プロジェクト: demas/stackify
def test_call_first_command():
    func = mock.MagicMock()
    c1 = Command(command_type=CommandType.EQUAL, value="a", action=func.foo)
    c2 = Command(command_type=CommandType.START_WITH,
                 value="a",
                 action=func.bar)
    parser = Parser()
    parser.add_command(c1)
    parser.add_command(c2)

    parser.process_message("a")

    assert func.foo.called
    assert not func.bar.called
コード例 #5
0
ファイル: start.py プロジェクト: demas/stackify
parser = Parser([
    Command(command_type=CommandType.EQUAL, value="init",
            action=commands.init),
    Command(command_type=CommandType.EQUAL,
            value="f",
            action=commands.fetch_and_ls),  # todo: get list of actions
    Command(command_type=CommandType.START_WITH,
            value="ls",
            action=commands.show_questions_by_tag),
    Command(command_type=CommandType.START_WITH,
            value="s ",
            action=commands.show_questions),
    Command(command_type=CommandType.START_WITH,
            value="sn ",
            action=commands.show_new_questions),
    Command(command_type=CommandType.START_WITH,
            value="del",
            action=commands.delete_questions),
    Command(command_type=CommandType.START_WITH,
            value="hide",
            action=commands.hide_tag),
    Command(command_type=CommandType.START_WITH,
            value="unhide",
            action=commands.unhide_tag),
    Command(command_type=CommandType.IN_LIST,
            value=POSITION_LIST,
            action=commands.open_question),
    Command(command_type=CommandType.START_WITH,
            value="o",
            action=commands.open_questions_list),
])
コード例 #6
0
"""
TheMoviePredictor script
Author: Arnaud de Mouhy <*****@*****.**>
"""
# Modules Imports
# import argparse

# import csv
# import imdb_scraper

# Local Imports
from cli import Parser
# from factory import Factory

parser = Parser()

# parser = argparse.ArgumentParser(description="Process MoviePredictor data")

# parser.add_argument(
#     "context",
#     choices=("people", "movies"),
#     help="Le contexte dans lequel nous allons travailler",
# )

# intermediateParser = parser.parse_known_args()
# commandContex = intermediateParser[0].context

# action_subparser = parser.add_subparsers(title="action", dest="action")

# # List
# list_parser = action_subparser.add_parser(