-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add E2E tests for evolution and move learning
- Loading branch information
Showing
19 changed files
with
242 additions
and
2 deletions.
There are no files selected for viewing
Binary file added
BIN
+54.3 KB
tests/states/emerald/in_tall_grass_before_levelling_up_and_evolving.ss1
Binary file not shown.
Binary file added
BIN
+53.9 KB
...tates/emerald/in_tall_grass_before_levelling_up_and_evolving_with_new_move_afterwards.ss1
Binary file not shown.
Binary file added
BIN
+53.6 KB
tests/states/emerald/in_tall_grass_before_levelling_up_and_evolving_with_new_move_before.ss1
Binary file not shown.
Binary file added
BIN
+53.5 KB
tests/states/emerald/in_tall_grass_before_levelling_up_and_learning_move_with_empty_slot.ss1
Binary file not shown.
Binary file added
BIN
+54 KB
...states/emerald/in_tall_grass_before_levelling_up_and_learning_move_with_no_empty_slot.ss1
Binary file not shown.
Binary file added
BIN
+49.5 KB
tests/states/firered/in_tall_grass_before_levelling_up_and_evolving.ss1
Binary file not shown.
Binary file added
BIN
+50.2 KB
...tates/firered/in_tall_grass_before_levelling_up_and_evolving_with_new_move_afterwards.ss1
Binary file not shown.
Binary file added
BIN
+50 KB
tests/states/firered/in_tall_grass_before_levelling_up_and_evolving_with_new_move_before.ss1
Binary file not shown.
Binary file added
BIN
+50.6 KB
tests/states/firered/in_tall_grass_before_levelling_up_and_learning_move_with_empty_slot.ss1
Binary file not shown.
Binary file added
BIN
+50.1 KB
...states/firered/in_tall_grass_before_levelling_up_and_learning_move_with_no_empty_slot.ss1
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+43.1 KB
...s/states/ruby/in_tall_grass_before_levelling_up_and_evolving_with_new_move_afterwards.ss1
Binary file not shown.
Binary file added
BIN
+43.2 KB
tests/states/ruby/in_tall_grass_before_levelling_up_and_evolving_with_new_move_before.ss1
Binary file not shown.
Binary file added
BIN
+43.6 KB
tests/states/ruby/in_tall_grass_before_levelling_up_and_learning_move_with_empty_slot.ss1
Binary file not shown.
Binary file added
BIN
+43.1 KB
tests/states/ruby/in_tall_grass_before_levelling_up_and_learning_move_with_no_empty_slot.ss1
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
from tests.utility import BotTestCase, with_save_state, with_frame_timeout | ||
|
||
|
||
class TestBattleEvolution(BotTestCase): | ||
@with_save_state( | ||
[ | ||
"emerald/in_tall_grass_before_levelling_up_and_evolving.ss1", | ||
"ruby/in_tall_grass_before_levelling_up_and_evolving.ss1", | ||
"firered/in_tall_grass_before_levelling_up_and_evolving.ss1", | ||
] | ||
) | ||
@with_frame_timeout(1500) | ||
def test_it_stops_evolution(self): | ||
from modules.config.schemas_v1 import Battle | ||
from modules.context import context | ||
from modules.modes import BattleAction | ||
from modules.modes.util import spin | ||
from modules.pokemon_party import get_party | ||
|
||
context.config.battle = Battle(stop_evolution=True) | ||
|
||
self.bot_mode.set_on_battle_started(lambda *args: BattleAction.Fight) | ||
previous_species = get_party()[0].species_name_for_stats | ||
previous_level = get_party()[0].level | ||
yield from spin(lambda: self.stats.last_encounter is not None and self.stats.last_encounter.outcome is not None) | ||
new_species = get_party()[0].species_name_for_stats | ||
new_level = get_party()[0].level | ||
self.assertGreater(new_level, previous_level) | ||
self.assertEqual(previous_species, new_species) | ||
|
||
@with_save_state( | ||
[ | ||
"emerald/in_tall_grass_before_levelling_up_and_evolving.ss1", | ||
"ruby/in_tall_grass_before_levelling_up_and_evolving.ss1", | ||
"firered/in_tall_grass_before_levelling_up_and_evolving.ss1", | ||
] | ||
) | ||
@with_frame_timeout(1500) | ||
def test_it_allows_evolution(self): | ||
from modules.config.schemas_v1 import Battle | ||
from modules.context import context | ||
from modules.modes import BattleAction | ||
from modules.modes.util import spin | ||
from modules.pokemon_party import get_party | ||
|
||
context.config.battle = Battle(stop_evolution=False) | ||
|
||
self.bot_mode.set_on_battle_started(lambda *args: BattleAction.Fight) | ||
previous_species = get_party()[0].species_name_for_stats | ||
previous_level = get_party()[0].level | ||
yield from spin(lambda: self.stats.last_encounter is not None and self.stats.last_encounter.outcome is not None) | ||
new_species = get_party()[0].species_name_for_stats | ||
new_level = get_party()[0].level | ||
self.assertGreater(new_level, previous_level) | ||
self.assertNotEqual(previous_species, new_species) | ||
|
||
@with_save_state( | ||
[ | ||
# In the `*_before.ss1`, the _pre-evolution_ will learn a move after levelling up | ||
# (i.e. learning _before_ the evolution happens.) | ||
"emerald/in_tall_grass_before_levelling_up_and_evolving_with_new_move_before.ss1", | ||
"ruby/in_tall_grass_before_levelling_up_and_evolving_with_new_move_before.ss1", | ||
"firered/in_tall_grass_before_levelling_up_and_evolving_with_new_move_before.ss1", | ||
# In the `*_after.ss1`, the _evolved Pokémon_ will learn a move (i.e. learning | ||
# _after_ the evolution happens.) | ||
"emerald/in_tall_grass_before_levelling_up_and_evolving_with_new_move_afterwards.ss1", | ||
"ruby/in_tall_grass_before_levelling_up_and_evolving_with_new_move_afterwards.ss1", | ||
"firered/in_tall_grass_before_levelling_up_and_evolving_with_new_move_afterwards.ss1", | ||
] | ||
) | ||
@with_frame_timeout(1500) | ||
def test_it_stops_evolution_with_new_move(self): | ||
from modules.config.schemas_v1 import Battle | ||
from modules.context import context | ||
from modules.modes import BattleAction | ||
from modules.modes.util import spin | ||
from modules.pokemon_party import get_party | ||
|
||
context.config.battle = Battle(stop_evolution=True, new_move="learn_best") | ||
|
||
self.bot_mode.set_on_battle_started(lambda *args: BattleAction.Fight) | ||
previous_species = get_party()[0].species_name_for_stats | ||
previous_level = get_party()[0].level | ||
yield from spin(lambda: self.stats.last_encounter is not None and self.stats.last_encounter.outcome is not None) | ||
new_species = get_party()[0].species_name_for_stats | ||
new_level = get_party()[0].level | ||
self.assertGreater(new_level, previous_level) | ||
self.assertEqual(previous_species, new_species) | ||
|
||
@with_save_state( | ||
[ | ||
"emerald/in_tall_grass_before_levelling_up_and_evolving_with_new_move_before.ss1", | ||
"emerald/in_tall_grass_before_levelling_up_and_evolving_with_new_move_afterwards.ss1", | ||
"ruby/in_tall_grass_before_levelling_up_and_evolving_with_new_move_before.ss1", | ||
"ruby/in_tall_grass_before_levelling_up_and_evolving_with_new_move_afterwards.ss1", | ||
"firered/in_tall_grass_before_levelling_up_and_evolving_with_new_move_before.ss1", | ||
"firered/in_tall_grass_before_levelling_up_and_evolving_with_new_move_afterwards.ss1", | ||
] | ||
) | ||
@with_frame_timeout(1500) | ||
def test_it_allows_evolution_with_new_move(self): | ||
from modules.config.schemas_v1 import Battle | ||
from modules.context import context | ||
from modules.modes import BattleAction | ||
from modules.modes.util import spin | ||
from modules.pokemon_party import get_party | ||
|
||
context.config.battle = Battle(stop_evolution=False, new_move="learn_best") | ||
|
||
self.bot_mode.set_on_battle_started(lambda *args: BattleAction.Fight) | ||
previous_species = get_party()[0].species_name_for_stats | ||
previous_level = get_party()[0].level | ||
previous_moves = [learned_move.move.name for learned_move in get_party()[0].moves] | ||
yield from spin(lambda: self.stats.last_encounter is not None and self.stats.last_encounter.outcome is not None) | ||
new_species = get_party()[0].species_name_for_stats | ||
new_level = get_party()[0].level | ||
new_moves = [learned_move.move.name for learned_move in get_party()[0].moves] | ||
self.assertGreater(new_level, previous_level) | ||
self.assertNotEqual(previous_moves, new_moves) | ||
self.assertNotEqual(previous_species, new_species) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
from tests.utility import BotTestCase, with_save_state, with_frame_timeout | ||
|
||
|
||
class TestBattleMoveLearning(BotTestCase): | ||
@with_save_state( | ||
[ | ||
"emerald/in_tall_grass_before_levelling_up_and_learning_move_with_empty_slot.ss1", | ||
"ruby/in_tall_grass_before_levelling_up_and_learning_move_with_empty_slot.ss1", | ||
"firered/in_tall_grass_before_levelling_up_and_learning_move_with_empty_slot.ss1", | ||
] | ||
) | ||
@with_frame_timeout(1000) | ||
def test_it_learns_move_with_empty_slot_available(self): | ||
from modules.modes import BattleAction | ||
from modules.modes.util import spin | ||
from modules.pokemon_party import get_party | ||
|
||
self.bot_mode.set_on_battle_started(lambda *args: BattleAction.Fight) | ||
previous_level = get_party()[0].level | ||
number_of_moves = len([move for move in get_party()[0].moves if move is not None]) | ||
yield from spin(lambda: get_party()[0].level > previous_level) | ||
new_number_of_moves = len([move for move in get_party()[0].moves if move is not None]) | ||
self.assertGreater(new_number_of_moves, number_of_moves) | ||
|
||
@with_save_state( | ||
[ | ||
"emerald/in_tall_grass_before_levelling_up_and_learning_move_with_no_empty_slot.ss1", | ||
"ruby/in_tall_grass_before_levelling_up_and_learning_move_with_no_empty_slot.ss1", | ||
"firered/in_tall_grass_before_levelling_up_and_learning_move_with_no_empty_slot.ss1", | ||
] | ||
) | ||
@with_frame_timeout(1500) | ||
def test_it_replaces_existing_move(self): | ||
from modules.config.schemas_v1 import Battle | ||
from modules.context import context | ||
from modules.modes import BattleAction | ||
from modules.modes.util import spin | ||
from modules.pokemon_party import get_party | ||
|
||
context.config.battle = Battle(new_move="learn_best") | ||
|
||
self.bot_mode.set_on_battle_started(lambda *args: BattleAction.Fight) | ||
previous_moves = [learned_move.move.name for learned_move in get_party()[0].moves if learned_move is not None] | ||
yield from spin(lambda: self.stats.last_encounter is not None and self.stats.last_encounter.outcome is not None) | ||
new_moves = [learned_move.move.name for learned_move in get_party()[0].moves if learned_move is not None] | ||
self.assertNotEqual(new_moves, previous_moves) | ||
|
||
@with_save_state( | ||
[ | ||
"emerald/in_tall_grass_before_levelling_up_and_learning_move_with_no_empty_slot.ss1", | ||
"ruby/in_tall_grass_before_levelling_up_and_learning_move_with_no_empty_slot.ss1", | ||
"firered/in_tall_grass_before_levelling_up_and_learning_move_with_no_empty_slot.ss1", | ||
] | ||
) | ||
@with_frame_timeout(1500) | ||
def test_it_does_not_learn_new_move(self): | ||
from modules.config.schemas_v1 import Battle | ||
from modules.context import context | ||
from modules.modes import BattleAction | ||
from modules.modes.util import spin | ||
from modules.pokemon_party import get_party | ||
|
||
context.config.battle = Battle(new_move="cancel") | ||
|
||
self.bot_mode.set_on_battle_started(lambda *args: BattleAction.Fight) | ||
previous_moves = [learned_move.move.name for learned_move in get_party()[0].moves if learned_move is not None] | ||
yield from spin(lambda: self.stats.last_encounter is not None and self.stats.last_encounter.outcome is not None) | ||
new_moves = [learned_move.move.name for learned_move in get_party()[0].moves if learned_move is not None] | ||
self.assertEqual(new_moves, previous_moves) | ||
|
||
@with_save_state( | ||
[ | ||
"emerald/in_tall_grass_before_levelling_up_and_learning_move_with_no_empty_slot.ss1", | ||
"ruby/in_tall_grass_before_levelling_up_and_learning_move_with_no_empty_slot.ss1", | ||
"firered/in_tall_grass_before_levelling_up_and_learning_move_with_no_empty_slot.ss1", | ||
] | ||
) | ||
@with_frame_timeout(1500) | ||
def test_it_switches_to_manual_when_having_to_replace_new_move(self): | ||
from modules.config.schemas_v1 import Battle | ||
from modules.context import context | ||
from modules.modes import BattleAction | ||
from modules.modes.util import spin | ||
from modules.pokemon_party import get_party | ||
|
||
context.config.battle = Battle(new_move="stop") | ||
|
||
self.bot_mode.set_on_battle_started(lambda *args: BattleAction.Fight) | ||
self.bot_mode.allow_ending_on_manual_mode = True | ||
|
||
previous_moves = [learned_move.move.name for learned_move in get_party()[0].moves if learned_move is not None] | ||
for _ in spin(lambda: self.stats.last_encounter is not None and self.stats.last_encounter.outcome is not None): | ||
if context.bot_mode == "Manual": | ||
break | ||
yield | ||
new_moves = [learned_move.move.name for learned_move in get_party()[0].moves if learned_move is not None] | ||
self.assertEqual(new_moves, previous_moves) | ||
self.assertIsInManualMode() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters