@@ -3552,24 +3552,71 @@ def test_env_vars_proton(self):
3552
3552
self .assertFalse (os .environ ["PROTONPATH" ])
3553
3553
3554
3554
def test_env_vars_wine (self ):
3555
- """Test check_env when setting only $WINEPREFIX."""
3556
- with (
3557
- self .assertRaisesRegex (ValueError , "GAMEID" ),
3558
- ThreadPoolExecutor () as thread_pool ,
3559
- ):
3555
+ """Test check_env when setting only $WINEPREFIX.
3556
+
3557
+ Expects GAMEID and PROTONPATH to be set for the command line:
3558
+ """
3559
+ result = None
3560
+ mock_gameid = "umu-default"
3561
+ mock_protonpath = str (self .test_proton_dir )
3562
+
3563
+ def mock_get_umu_proton ():
3564
+ os .environ ["PROTONPATH" ] = mock_protonpath
3565
+ return self .env
3566
+
3567
+ # Mock setting the PROTONPATH
3568
+ # When running `WINEPREFIX=/some/path umu-run foo.exe` Proton is installed
3569
+ # and the GAMEID is 'umu-default'
3570
+ with patch .object (umu_run , "get_umu_proton" , new_callable = mock_get_umu_proton ):
3560
3571
os .environ ["WINEPREFIX" ] = self .test_file
3561
- umu_run .check_env (self .env , thread_pool )
3572
+ result = umu_run .check_env (self .env , self .test_session_pools )
3573
+ self .assertTrue (result , self .env )
3574
+ self .assertEqual (os .environ ["GAMEID" ], mock_gameid )
3575
+ self .assertEqual (os .environ ["GAMEID" ], self .env ["GAMEID" ])
3576
+ self .assertEqual (os .environ ["PROTONPATH" ], mock_protonpath )
3577
+ self .assertEqual (os .environ ["PROTONPATH" ], mock_protonpath )
3578
+ self .assertTrue (
3579
+ Path (os .environ ["WINEPREFIX" ]).is_dir (), "Expected WINEPREFIX to exist"
3580
+ )
3562
3581
3563
3582
def test_env_vars_none (self ):
3564
3583
"""Tests check_env when setting no env vars.
3565
3584
3566
- GAMEID should be the only strictly required env var
3585
+ Expects PROTONPATH, GAMEID, and WINEPREFIX to be set
3567
3586
"""
3587
+ result = None
3588
+ mock_gameid = "umu-default"
3589
+ mock_protonpath = str (self .test_proton_dir )
3590
+ mock_wineprefix = "/home/foo/Games/umu/umu-default"
3591
+
3592
+ def mock_get_umu_proton ():
3593
+ os .environ ["PROTONPATH" ] = mock_protonpath
3594
+ return self .env
3595
+
3596
+ def mock_set_wineprefix ():
3597
+ os .environ ["WINEPREFIX" ] = mock_wineprefix
3598
+ return
3599
+
3600
+ # Mock setting the PROTONPATH and the WINEPREFIX creation
3601
+ # When running `umu-run foo.exe` Proton is installed WINE prefix is created
3602
+ # where the directory is 'umu-default', and the GAMEID is 'umu-default'
3568
3603
with (
3569
- self . assertRaisesRegex ( ValueError , "GAMEID" ),
3570
- ThreadPoolExecutor () as thread_pool ,
3604
+ patch . object ( umu_run , "get_umu_proton" , new_callable = mock_get_umu_proton ),
3605
+ patch . object ( Path , "mkdir" , return_value = mock_set_wineprefix ()) ,
3571
3606
):
3572
- umu_run .check_env (self .env , thread_pool )
3607
+ result = umu_run .check_env (self .env , self .test_session_pools )
3608
+ self .assertTrue (result , self .env )
3609
+ self .assertEqual (os .environ ["GAMEID" ], mock_gameid )
3610
+ self .assertEqual (os .environ ["GAMEID" ], self .env ["GAMEID" ])
3611
+ self .assertEqual (os .environ ["PROTONPATH" ], mock_protonpath )
3612
+ self .assertEqual (os .environ ["PROTONPATH" ], self .env ["PROTONPATH" ])
3613
+ self .assertEqual (os .environ ["WINEPREFIX" ], mock_wineprefix )
3614
+ self .assertEqual (os .environ ["WINEPREFIX" ], self .env ["WINEPREFIX" ])
3615
+
3616
+ # Assert only PROTONPATH as WINEPREFIX involves $HOME
3617
+ self .assertTrue (
3618
+ self .test_proton_dir .is_dir (), "Expected PROTONPATH to exist"
3619
+ )
3573
3620
3574
3621
3575
3622
if __name__ == "__main__" :
0 commit comments