def test_move_character_boundary_output(self, mock_stdout, mock_user_input): """Assert expected print output if user it out of bounds.""" random.seed(3) pokemon['Position'][0] = 7 expected_output = '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🐱\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n' \ 'You head East out of bounds and step in mud! '\ 'You go back to your original position, to clean your feet\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🐱\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n' \ '🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n' \ 'You head towards the grass and continue on your path.\n' move_character() self.assertEqual(mock_stdout.getvalue(), expected_output) random.seed()
def test_move_character_north(self): row_before_move = rebel["Row"] move_character("n") self.assertEqual(rebel["Row"], row_before_move - 1)
def test_move_character_west(self): column_before_move = rebel["Column"] move_character("w") self.assertEqual(rebel["Column"], column_before_move - 1)
def test_move_character_south(self): row_before_move = rebel["Row"] move_character("s") self.assertEqual(rebel["Row"], row_before_move + 1)
def test_user_input_type_quit_lower(self, mock_user_input): """Assert SystemExit is raised when input is Quit.""" with self.assertRaises(SystemExit): move_character()
def test_move_character_column_boundary(self, mock_user_input): """Assert that character column position cannot move out of bounds and user must select different direction""" pokemon['Position'][1] = 0 expected_output = 1 move_character() self.assertEqual(get_column(), expected_output)
def test_move_character_hp_max(self, mock_user_input): """Assert that HP will not be greater than 10.""" pokemon['HP'] = 10 move_character() self.assertEqual(get_hp(), 10)
def test_move_character_row_boundary(self, mock_user_input): """Assert that character cannot move out of bounds and select a different direction.""" pokemon['Position'][0] = 7 expected_output = 6 move_character() self.assertEqual(get_row(), expected_output)
def test_move_character_hp(self, mock_user_input): """Assert that HP will increase by one if HP is less than 10.""" move_character() self.assertEqual(get_hp(), 9)
def test_move_character_north(self, mock_user_input): """Assert that character column position is subtracted by one.""" move_character() self.assertEqual(get_column(), 1)
def test_move_character_west(self, mock_user_input): """Assert that character row position is subtracted by one.""" move_character() self.assertEqual(get_row(), 0)