mirror of
https://github.com/LazoCoder/Pokemon-Terminal
synced 2024-11-23 12:23:04 +00:00
More testing
- Main resets the pokemon list if not called directly
This commit is contained in:
parent
d96d4a8bb5
commit
cc51b5d957
2 changed files with 22 additions and 8 deletions
6
main.py
6
main.py
|
@ -53,6 +53,11 @@ def slideshow(db, start, end, seconds="0.25", rand=False):
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
"""Entrance to the program."""
|
"""Entrance to the program."""
|
||||||
|
|
||||||
|
if __name__ != "__main__":
|
||||||
|
Filter.filtered_list = [pok for pok in Filter.POKEMON_LIST]
|
||||||
|
print("MAIN CALLED FOR TESTING. THE LENGTH OF THE FILTERED LIST IS",
|
||||||
|
len(Filter.filtered_list))
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Set a pokemon to the current terminal background or '
|
description='Set a pokemon to the current terminal background or '
|
||||||
'wallpaper',
|
'wallpaper',
|
||||||
|
@ -146,6 +151,7 @@ def main(argv):
|
||||||
else:
|
else:
|
||||||
print("Invalid id specified")
|
print("Invalid id specified")
|
||||||
return
|
return
|
||||||
|
|
||||||
if options.dry_run:
|
if options.dry_run:
|
||||||
options.verbose = True
|
options.verbose = True
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
|
|
24
test_main.py
24
test_main.py
|
@ -38,33 +38,41 @@ def broken_test_two_letters(capsys):
|
||||||
|
|
||||||
|
|
||||||
def test_extra(capsys):
|
def test_extra(capsys):
|
||||||
main(['-e'])
|
main(['-e', '-dr'])
|
||||||
# TODO: Assertion based on number of files on ./Extras
|
# TODO: Assertion based on number of files on ./Extras
|
||||||
assert str(random.choice(Filter.filtered_list)).startswith('---')
|
assert str(random.choice(Filter.filtered_list)).startswith('---')
|
||||||
|
|
||||||
|
|
||||||
def test_region_names(capsys):
|
def test_region_names(capsys):
|
||||||
try:
|
try:
|
||||||
main(['-r', 'wrong_region'])
|
main(['-r', 'wrong_region', '-dr'])
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
pass # It's supposed to crash.
|
pass # It's supposed to crash.
|
||||||
err: str = capsys.readouterr()[1].strip()
|
err: str = capsys.readouterr()[1].strip()
|
||||||
assert err.endswith("(choose from 'kanto', 'johto', 'hoenn', 'sinnoh')")
|
assert err.endswith("(choose from 'kanto', 'johto', 'hoenn', 'sinnoh')")
|
||||||
|
|
||||||
|
|
||||||
def region_test(capsys, region_name):
|
def test_all(capsys):
|
||||||
regFilter = filters.RegionFilter()
|
main(['-dr', '-ne'])
|
||||||
noExtras = filters.NonExtrasFilter()
|
out = capsys.readouterr()[0]
|
||||||
|
for region_info in region_dict.values():
|
||||||
|
assert (region_info.first or '') in out # convert None --> ''
|
||||||
|
assert (region_info.last or '') in out # convert None --> ''
|
||||||
|
|
||||||
|
|
||||||
|
def test_region(capsys):
|
||||||
|
regFilter = filters.RegionFilter(None, None)
|
||||||
|
noExtras = filters.NonExtrasFilter(None, None)
|
||||||
# matrix test of first pokemon name and last pokemon name from all regions
|
# matrix test of first pokemon name and last pokemon name from all regions
|
||||||
for name, region_info in region_dict.items():
|
for name, region_info in region_dict.items():
|
||||||
filtered = [p for p in Filter.POKEMON_LIST
|
filtered = [p for p in Filter.POKEMON_LIST
|
||||||
if regFilter.matches(p, name) and noExtras.matches(p)]
|
if regFilter.matches(p, name) and noExtras.matches(p, None)]
|
||||||
assert len(filtered) == region_info.size
|
assert len(filtered) == region_info.size
|
||||||
assert random.choice(filtered).get_region() == name
|
assert random.choice(filtered).get_region() == name
|
||||||
assert filtered[0].get_id() == ('%03d' % (region_info.start))
|
assert filtered[0].get_id() == ('%03d' % (region_info.start))
|
||||||
assert filtered[-1].get_id() == ('%03d' % (region_info.end))
|
assert filtered[-1].get_id() == ('%03d' % (region_info.end))
|
||||||
assert filtered[0].get_name() == region_info.first
|
assert filtered[0].get_name() == region_info.first.lower()
|
||||||
assert filtered[-1].get_name() == region_info.last
|
assert filtered[-1].get_name() == region_info.last.lower()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in a new issue