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
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
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
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
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), ])
""" 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(