<s> import unittest <EOL> from modules . bag import Bag <EOL> from modules . item import Item <EOL> class InventoryBagTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . bag = Bag ( ) <EOL> def tearDown ( self ) : <EOL> self . bag = None <EOL> def test_can_use_bag_to_hold_items_that_are_found ( self ) : <EOL> self . assertIsNotNone ( self . bag ) <EOL> self . assertTrue ( self . bag . is_empty ( ) ) <EOL> self . assertEqual ( self . bag . item_count ( ) , <NUM_LIT:0> ) <EOL> rock = Item ( "<STR_LIT>" ) <EOL> self . bag . add ( rock ) <EOL> self . assertFalse ( self . bag . is_empty ( ) ) <EOL> self . assertEqual ( self . bag . item_count ( ) , <NUM_LIT:1> ) <EOL> seen = self . bag . look ( ) <EOL> self . assertIn ( "<STR_LIT>" , seen ) <EOL> self . bag . add ( rock ) <EOL> another_rock = Item ( "<STR_LIT>" ) <EOL> self . bag . add ( another_rock ) <EOL> self . assertEqual ( self . bag . item_count ( ) , <NUM_LIT:3> ) <EOL> seen = self . bag . look ( ) <EOL> self . assertIn ( "<STR_LIT>" , seen ) <EOL> dagger = Item ( "<STR_LIT>" ) <EOL> self . bag . add ( dagger ) <EOL> seen = self . bag . look ( ) <EOL> self . assertIn ( "<STR_LIT>" , seen ) <EOL> def test_items_are_removed_from_bag ( self ) : <EOL> self . bag . add ( Item ( "<STR_LIT>" ) ) <EOL> self . bag . add ( Item ( "<STR_LIT>" ) ) <EOL> self . bag . add ( Item ( "<STR_LIT>" ) ) <EOL> self . bag . add ( Item ( "<STR_LIT>" ) ) <EOL> self . bag . add ( Item ( "<STR_LIT>" ) ) <EOL> self . bag . add ( Item ( "<STR_LIT>" ) ) <EOL> self . bag . add ( Item ( "<STR_LIT>" ) ) <EOL> self . bag . add ( Item ( "<STR_LIT>" ) ) <EOL> self . bag . add ( Item ( "<STR_LIT>" ) ) <EOL> self . bag . add_many ( Item ( "<STR_LIT>" ) , <NUM_LIT:5> ) <EOL> self . bag . add ( Item ( "<STR_LIT>" ) ) <EOL> self . bag . add ( Item ( "<STR_LIT>" ) ) <EOL> self . bag . add_many ( Item ( "<STR_LIT>" ) , <NUM_LIT:3> ) <EOL> total_items = self . bag . item_count ( ) <EOL> self . assertTrue ( total_items >= <NUM_LIT> ) <EOL> hatrack_count = self . bag . how_many ( "<STR_LIT>" ) <EOL> self . bag . remove ( "<STR_LIT>" ) <EOL> self . assertEqual ( hatrack_count - <NUM_LIT:1> , self . bag . how_many ( "<STR_LIT>" ) ) <EOL> self . bag . add ( Item ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( hatrack_count , self . bag . how_many ( "<STR_LIT>" ) ) <EOL> med_count , medicine = self . bag . remove ( "<STR_LIT>" ) <EOL> self . assertEqual ( med_count , <NUM_LIT:1> ) <EOL> self . assertIsInstance ( medicine , Item ) <EOL> self . assertEqual ( medicine . name , "<STR_LIT>" ) <EOL> teaspoon_count , teaspoon = self . bag . remove_many ( "<STR_LIT>" , <NUM_LIT:2> ) <EOL> self . assertEqual ( teaspoon_count , <NUM_LIT:1> ) <EOL> self . assertEqual ( self . bag . how_many ( "<STR_LIT>" ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( teaspoon . name , "<STR_LIT>" ) <EOL> sugar_count , sugar = self . bag . remove ( "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:1> , sugar_count ) <EOL> sugar_count , sugar = self . bag . remove ( "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:1> , sugar_count ) <EOL> sugar_count , sugar = self . bag . remove ( "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:1> , sugar_count ) <EOL> new_total_items = self . bag . item_count ( ) <EOL> self . assertEqual ( <NUM_LIT:5> , total_items - new_total_items ) <EOL> self . bag . add ( teaspoon ) <EOL> self . bag . add ( medicine ) <EOL> self . assertTrue ( self . bag . item_count ( ) >= <NUM_LIT:12> ) <EOL> def test_items_are_dumped_into_a_pile ( self ) : <EOL> rock = Item ( "<STR_LIT>" ) <EOL> self . bag . add ( rock ) <EOL> pile = self . bag . dump ( ) <EOL> item_list = pile . keys ( ) <EOL> self . assertEqual ( len ( item_list ) , <NUM_LIT:1> ) <EOL> self . assertIn ( "<STR_LIT>" , item_list ) <EOL> item = pile [ "<STR_LIT>" ] <EOL> self . assertEqual ( item [ "<STR_LIT:name>" ] , "<STR_LIT>" ) <EOL> self . assertEqual ( item [ "<STR_LIT:count>" ] , <NUM_LIT:1> ) </s>
