示例#1
0
文件: Export.py 项目: pysudoku/sudoku
    def execute(self):
        '''
        execute the command taking account the parameters of the command
        '''
        
        if self.game == None:
            raise InvalidCmdParametersException("The command needs a game.")
        elif self.game.initial_sudoku == None:
            raise InvalidCmdParametersException("The Sudoku was not loaded.")

        writer_factory = WriterFactory('txt')
        writer = writer_factory.getWriter()
        writer.write(self.game.initial_sudoku.to_dictionary(), self.readconfig_parameters[self.OUTPUT_PARAM])
示例#2
0
 def test_factory_should_return_a_console_writer(self):
     writer_factory = WriterFactory('console')
     writer = writer_factory.getWriter()
     self.assertEqual(DisplayCMD, type(writer))
示例#3
0
 def test_having_txt_file_should_return_a_txt_file_writer(self):
     writer_factory = WriterFactory('txt')
     writer = writer_factory.getWriter()
     self.assertEqual(WriterTXT, type(writer))
示例#4
0
 def test_having_csv_file_should_return_a_csv_file_writer(self):
     writer_factory = WriterFactory('csv')
     writer = writer_factory.getWriter()
     self.assertEqual(WriterCSV, type(writer))