コード例 #1
0
ファイル: test_steam.py プロジェクト: Matoking/protontricks
    def test_steam_app_from_appmanifest_permission_denied(
            self, steam_app_factory, caplog, monkeypatch):
        """
        Test trying to read a SteamApp manifest that the user doesn't
        have read permission for
        """
        def _mock_read_text(self, encoding=None):
            """
            Mock `pathlib.Path.read_text` that mimics a failure due to
            insufficient permissions
            """
            raise PermissionError("Permission denied")

        steam_app = steam_app_factory(name="Fake game", appid=10)

        appmanifest_path = \
            Path(steam_app.install_path).parent.parent / "appmanifest_10.acf"

        monkeypatch.setattr("pathlib.Path.read_text", _mock_read_text)

        assert not SteamApp.from_appmanifest(path=appmanifest_path,
                                             steam_lib_paths=[])

        record = caplog.records[-1]
        assert record.getMessage() == (
            "Skipping appmanifest {} due to insufficient permissions".format(
                str(appmanifest_path)))
コード例 #2
0
    def test_steam_app_from_appmanifest_empty(self, steam_app_factory):
        steam_app = steam_app_factory(name="Fake game", appid=10)

        appmanifest_path = \
            Path(steam_app.install_path).parent.parent / "appmanifest_10.acf"
        appmanifest_path.write_text("")

        # Empty appmanifest file is ignored
        assert not SteamApp.from_appmanifest(path=str(appmanifest_path),
                                             steam_lib_paths=[])
コード例 #3
0
ファイル: test_steam.py プロジェクト: Matoking/protontricks
    def test_steam_app_from_appmanifest_invalid(self, steam_app_factory,
                                                content):
        steam_app = steam_app_factory(name="Fake game", appid=10)

        appmanifest_path = \
            Path(steam_app.install_path).parent.parent / "appmanifest_10.acf"
        appmanifest_path.write_bytes(content)

        # Invalid appmanifest file is ignored
        assert not SteamApp.from_appmanifest(path=appmanifest_path,
                                             steam_lib_paths=[])
コード例 #4
0
ファイル: test_steam.py プロジェクト: Matoking/protontricks
    def test_steam_app_from_appmanifest_empty(self, steam_app_factory):
        """
        Try to deserialize an empty appmanifest and check that no SteamApp
        is returned
        """
        steam_app = steam_app_factory(name="Fake game", appid=10)

        appmanifest_path = \
            Path(steam_app.install_path).parent.parent / "appmanifest_10.acf"
        appmanifest_path.write_text("")

        # Empty appmanifest file is ignored
        assert not SteamApp.from_appmanifest(path=appmanifest_path,
                                             steam_lib_paths=[])
コード例 #5
0
    def test_steam_app_from_appmanifest(self, steam_app_factory, steam_dir):
        """
        Create a SteamApp from an appmanifest file
        """
        steam_app = steam_app_factory(name="Fake game", appid=10)

        appmanifest_path = \
            Path(steam_app.install_path).parent.parent / "appmanifest_10.acf"

        steam_app = SteamApp.from_appmanifest(
            path=str(appmanifest_path),
            steam_lib_paths=[str(steam_dir / "steam" / "steamapps")])

        assert steam_app.name == "Fake game"
        assert steam_app.appid == 10
コード例 #6
0
ファイル: test_steam.py プロジェクト: Matoking/protontricks
    def test_steam_app_from_appmanifest_corrupted_toolmanifest(
            self, steam_runtime_soldier, proton_factory, caplog, content):
        """
        Test trying to a SteamApp manifest from an incomplete
        Proton installation with an empty or corrupted toolmanifest.vdf file
        """
        proton_app = proton_factory(name="Proton 5.13",
                                    appid=10,
                                    compat_tool_name="proton_513",
                                    required_tool_app=steam_runtime_soldier)
        # Empty the "toolmanifest.vdf" file
        (proton_app.install_path / "toolmanifest.vdf").write_bytes(content)

        assert not SteamApp.from_appmanifest(
            path=proton_app.install_path.parent.parent / "appmanifest_10.acf",
            steam_lib_paths=[])

        assert len(caplog.records) == 1
        record = caplog.records[0]

        assert "Tool manifest for Proton 5.13 is empty" in record.message
コード例 #7
0
ファイル: test_steam.py プロジェクト: Matoking/protontricks
    def test_steam_app_userconfig_name(self, steam_app_factory):
        """
        Try creating a SteamApp from an older version of the app manifest
        which contains the application name in a different field

        See GitHub issue #103 for details
        """
        steam_app = steam_app_factory(name="Fake game", appid=10)

        appmanifest_path = \
            Path(steam_app.install_path).parent.parent / "appmanifest_10.acf"
        data = vdf.loads(appmanifest_path.read_text())

        # Older installations store the name in `userconfig/name` instead
        del data["AppState"]["name"]
        data["AppState"]["userconfig"] = {"name": "Fake game"}

        appmanifest_path.write_text(vdf.dumps(data))

        app = SteamApp.from_appmanifest(path=appmanifest_path,
                                        steam_lib_paths=[])

        assert app.name == "Fake game"