Пример #1
0
 def test_a_game_file_should_be_read(self):
     game = Game()
     game.initial_sudoku = SudokuBoard()
     game.initial_sudoku.from_dictionary(self.puzzle, True)
     with open('test_game_file.sgf', 'wb') as output_file:
         pickle.dump(game, output_file, pickle.HIGHEST_PROTOCOL)
     
     game_reader = SudokuGameReader()
     read_game_file = game_reader.read_game('test_game_file.sgf')
     self.assertEqual(game.initial_sudoku.to_dictionary(), read_game_file.initial_sudoku.to_dictionary())
Пример #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.")

        game_reader = SudokuGameReader()
        working_directory = self.game.settings_manager.settings.getPath()
        if working_directory == "":
            working_directory = os.getcwd()

        file_name = self.readconfig_parameters[self.INPUT_PARAM]
        if os.path.dirname(file_name) == "":
            file_name = working_directory + os.sep + file_name

        read_game = game_reader.read_game(file_name)
        self.game.copy(read_game)
        if self.game.is_started():
            self.game.stop_game_timer()
Пример #3
0
 def test_an_exception_should_be_raised_when_the_path_is_invalid(self):
     with self.assertRaises(FileNotFoundError):
         game_reader = SudokuGameReader()
         read_game_file = game_reader.read_game('test_game_file.sgf')
Пример #4
0
 def test_a_FileFormatError_should_be_raised_when_the_file_is_not_a_sudoku_game_file(self):
     with self.assertRaises(FileFormatError):
         game_reader = SudokuGameReader()
         read_game_file = game_reader.read_game('test_game_file.txt')