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):
|
||||
"""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(
|
||||
description='Set a pokemon to the current terminal background or '
|
||||
'wallpaper',
|
||||
|
@ -146,6 +151,7 @@ def main(argv):
|
|||
else:
|
||||
print("Invalid id specified")
|
||||
return
|
||||
|
||||
if options.dry_run:
|
||||
options.verbose = True
|
||||
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):
|
||||
main(['-e'])
|
||||
main(['-e', '-dr'])
|
||||
# TODO: Assertion based on number of files on ./Extras
|
||||
assert str(random.choice(Filter.filtered_list)).startswith('---')
|
||||
|
||||
|
||||
def test_region_names(capsys):
|
||||
try:
|
||||
main(['-r', 'wrong_region'])
|
||||
main(['-r', 'wrong_region', '-dr'])
|
||||
except SystemExit:
|
||||
pass # It's supposed to crash.
|
||||
err: str = capsys.readouterr()[1].strip()
|
||||
assert err.endswith("(choose from 'kanto', 'johto', 'hoenn', 'sinnoh')")
|
||||
|
||||
|
||||
def region_test(capsys, region_name):
|
||||
regFilter = filters.RegionFilter()
|
||||
noExtras = filters.NonExtrasFilter()
|
||||
def test_all(capsys):
|
||||
main(['-dr', '-ne'])
|
||||
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
|
||||
for name, region_info in region_dict.items():
|
||||
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 random.choice(filtered).get_region() == name
|
||||
assert filtered[0].get_id() == ('%03d' % (region_info.start))
|
||||
assert filtered[-1].get_id() == ('%03d' % (region_info.end))
|
||||
assert filtered[0].get_name() == region_info.first
|
||||
assert filtered[-1].get_name() == region_info.last
|
||||
assert filtered[0].get_name() == region_info.first.lower()
|
||||
assert filtered[-1].get_name() == region_info.last.lower()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in a new issue