Example #1
0
class TestParserFactory(unittest.TestCase):


    def setUp(self):
        self.parser_factory = ParserFactory()

    def test_a_TXTParser_should_be_returned_when_a_text_file_parser_is_requested(self):
        self.assertIsInstance(self.parser_factory.get_parser('.txt'), TXTParser)

    def test_a_CSVParser_should_be_returned_when_a_csv_file_parser_is_requested(self):
        self.assertIsInstance(self.parser_factory.get_parser('.csv'), CSVParser)
             
    def test_a_CommandLineParser_should_be_returned_when_the_parameter_is_not_sudoku_file(self):
        puzzle_param = '067040002900730450405000000600080000000900320283500649070000003000657804006423597'
        self.assertIsInstance(self.parser_factory.get_parser(puzzle_param), CommandLineParser)
Example #2
0
    def execute(self):
        '''
        execute the command taking account the parameters of the command
        '''
        if self.game == None:
            raise InvalidCmdParametersException("The command needs a game.")
        
        parser_factory = ParserFactory()
        parser = parser_factory.get_parser(self.readconfig_parameters[self.INPUT_PARAM])
        puzzle =  parser.parse_puzzle(self.readconfig_parameters[self.INPUT_PARAM])
        self.game.initial_sudoku = SudokuBoard()
        self.game.initial_sudoku.from_dictionary(puzzle, True)
        self.game.user_sudoku = SudokuBoard()
        self.game.user_sudoku.from_dictionary(puzzle, True)
        self.game.solved_sudoku = None

        if self.game.is_started():
            self.game.stop_game_timer()
Example #3
0
 def setUp(self):
     self.parser_factory = ParserFactory()