Test buying an item when we don't have enough of money

This commit is contained in:
Yohann D'ANELLO
2020-12-11 17:28:16 +01:00
parent 7179346e2b
commit 99352bc1d5
3 changed files with 17 additions and 24 deletions

View File

@ -528,6 +528,15 @@ class TestGame(unittest.TestCase):
self.assertEqual(self.game.player.health,
self.game.player.maxhealth - 1)
# We don't have enough of money
self.game.player.hazel = 0
item = self.game.store_menu.validate()
self.game.handle_key_pressed(KeyValues.ENTER)
self.assertNotIn(item, self.game.player.inventory)
self.assertIn(item, merchant.inventory)
self.assertEqual(self.game.message, _("You do not have enough money"))
self.game.handle_key_pressed(KeyValues.ENTER)
# Exit the menu
self.game.handle_key_pressed(KeyValues.SPACE)
self.assertEqual(self.game.state, GameMode.PLAY)