test_interface.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # -*- coding: utf8 -*-
  2. # libray - Libre Blu-Ray PS3 ISO Tool
  3. # Copyright © 2018 - 2024 Nichlas Severinsen
  4. #
  5. # This file is part of libray.
  6. #
  7. # libray is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # libray is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with libray. If not, see <https://www.gnu.org/licenses/>.
  19. # This is a script to find the redump names and game serial id's using rpcs3's compatibility list.
  20. # It puts the name, serial id, and some other info into an sqlite3 database.
  21. # That database can then be used to harcode serial id to keys into keys.db.
  22. # This script is not included in the release of libray.
  23. import io
  24. import argparse
  25. import builtins
  26. import unittest
  27. import unittest.mock
  28. import libray
  29. class TestInterface(unittest.TestCase):
  30. @unittest.skip('currently broken')
  31. @unittest.mock.patch('argparse.ArgumentParser.parse_args', return_value=argparse.Namespace())
  32. def test_decrypt_with_key(self, mock_args):
  33. os_stat = unittest.mock.Mock()
  34. os_stat.return_value.st_mode = 33188
  35. iso_filepath = unittest.mock.Mock()
  36. iso_filepath.open = unittest.mock.mock_open(read_data=b"some initial binary data: \x00\x01")
  37. iso_filepath.is_file.return_value = True
  38. iso_filepath.stat.return_value = unittest.mock.MagicMock()
  39. iso_filepath.stat.st_size = 1024
  40. iso_filepath.stat.st_mode = 33188
  41. iso_filepath.stat.S_ISBLK.return_value = False
  42. mock_args.iso = 'encrypted_mock.iso'
  43. #mock_args.iso = iso_filepath
  44. with unittest.mock.patch('os.stat', os_stat):
  45. with unittest.mock.patch('builtins.open', iso_filepath.open):
  46. libray.core.decrypt(mock_args)