Skip to content

Commit

Permalink
SporeModManager: add uninstall range tests to test.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Jan 5, 2024
1 parent 3ab49e6 commit 821572d
Showing 1 changed file with 40 additions and 16 deletions.
56 changes: 40 additions & 16 deletions SporeModManager/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,6 @@ def test_install():
assert result.stdout == b''
assert result.stderr != b''

# TODO: add more validation to SporeModManager
# and then add more tests here

# Tests whether uninstall works correctly
def test_uninstall():
print(f'Running {test_uninstall.__name__}...')
Expand All @@ -382,21 +379,23 @@ def test_uninstall():
assert result.stdout == b''
assert result.stderr != b''

# install a dummy mod
xml = """<mod displayName="test_uninstall"
unique="test_uninstall"
description="test_uninstall"
installerSystemVersion="1.0.1.1"
dllsBuild="2.5.20">
</mod>"""
write_sporemod(xml)
result = run_smm([ 'install', sporemod_file ])
assert result.returncode == 0
assert result.stdout != b''
assert result.stderr == b''
# install a dummy mods
# TODO: rewrite this to use a single install command
for num in range(25):
xml = f"""<mod displayName="test_uninstall_{num}"
unique="test_uninstall_{num}"
description="test_uninstall_{num}"
installerSystemVersion="1.0.1.1"
dllsBuild="2.5.20">
</mod>"""
write_sporemod(xml)
result = run_smm([ 'install', sporemod_file ])
assert result.returncode == 0
assert result.stdout != b''
assert result.stderr == b''

# uninstall with a too high ID shouldn't work
result = run_smm([ 'uninstall', '1'])
result = run_smm([ 'uninstall', '26'])
assert result.returncode != 0
assert result.stdout == b''
assert result.stderr != b''
Expand All @@ -407,6 +406,31 @@ def test_uninstall():
assert result.stdout != b''
assert result.stderr == b''

# uninstall with a valid range should work
result = run_smm([ 'uninstall', '0-20'])
assert result.returncode == 0
assert result.stdout != b''
assert result.stderr == b''

# uninstall with an invalid range shouldn't work
result = run_smm([ 'uninstall', '0-30'])
assert result.returncode != 0
assert result.stdout == b''
assert result.stderr != b''

# uninstall with another invalid range shouldn't work
result = run_smm([ 'uninstall', '10-0'])
assert result.returncode != 0
assert result.stdout == b''
assert result.stderr != b''

# uninstall with an insanely big range shouldn't work or crash
result = run_smm([ 'uninstall', '0-2147483646'])
assert result.returncode != 0
assert result.stdout == b''
assert result.stderr != b''


# Tests whether update works correctly
def test_update():
print(f'Running {test_update.__name__}...')
Expand Down

0 comments on commit 821572d

Please sign in to comment.