Skip to content

Commit

Permalink
fixup protonfixes test for title fetch function rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
GloriousEggroll committed Oct 15, 2024
1 parent e404c14 commit e3b259c
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions protonfixes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,20 +295,18 @@ def testGetGameName(self):
def testGetGameNameDB(self):
"""Set UMU_ID and access umu database
Makes a request to the umu database for a title name to be displayed
if a UMU_ID is supplied. This function should be fail safe in case of
a TimeoutError, OSError, IndexError or UnicodeDecodeError
Reads from a local CSV file for a title name to be displayed
if a UMU_ID is supplied.
"""
os.environ['UMU_ID'] = 'umu-35140'
os.environ['WINEPREFIX'] = self.pfx.as_posix()
# Mock a valid umu db response
data = '[{"title":"Batman: Arkham Asylum Game of the Year Edition","umu_id":"umu-35140","acronym":null,"codename":"1482504285","store":"gog","notes":null},{"title":"Batman: Arkham Asylum Game of the Year Edition","umu_id":"umu-35140","acronym":null,"codename":"godwit","store":"egs","notes":null}]'
data = io.StringIO(data)
with (
patch.object(fix, 'check_internet', return_value=True),
patch.object(urllib.request, 'urlopen', return_value=data),
):
func = fix.get_game_name.__wrapped__ # Do not reference the cache
os.environ['STORE'] = 'gog'
os.environ['WINEPREFIX'] = self.pfx

# Mock CSV content
csv_content = """Batman: Arkham Asylum Game of the Year Edition,gog,1482504285,umu-35140,,"""

with patch('builtins.open', mock_open(read_data=csv_content)):
func = fix.get_game_name # Reference the function directly
result = func()
self.assertEqual(result, 'Batman: Arkham Asylum Game of the Year Edition')

Expand Down

0 comments on commit e3b259c

Please sign in to comment.