<s> """<STR_LIT>""" <EOL> from hamcrest import assert_that , equal_to , is_ <EOL> from mockito import any , mock , verify <EOL> from pyherc . data import Model , add_item , get_items <EOL> from pyherc . ports import pick_up , set_action_factory <EOL> from pyherc . test . builders import ( ActionFactoryBuilder , CharacterBuilder , <EOL> ItemBuilder , LevelBuilder ) <EOL> class TestPickingUp ( ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( TestPickingUp , self ) . __init__ ( ) <EOL> self . item = None <EOL> self . level = None <EOL> self . character = None <EOL> def setup ( self ) : <EOL> """<STR_LIT>""" <EOL> self . item = ( ItemBuilder ( ) <EOL> . build ( ) ) <EOL> self . model = Model ( ) <EOL> self . level = LevelBuilder ( ) . build ( ) <EOL> self . character = ( CharacterBuilder ( ) <EOL> . with_location ( ( <NUM_LIT:5> , <NUM_LIT:5> ) ) <EOL> . with_level ( self . level ) <EOL> . with_model ( self . model ) <EOL> . build ( ) ) <EOL> add_item ( self . level , ( <NUM_LIT:5> , <NUM_LIT:5> ) , self . item ) <EOL> set_action_factory ( ActionFactoryBuilder ( ) <EOL> . with_inventory_factory ( ) <EOL> . build ( ) ) <EOL> def test_picking_up ( self ) : <EOL> """<STR_LIT>""" <EOL> pick_up ( self . character , <EOL> self . item ) <EOL> assert ( self . item in self . character . inventory ) <EOL> assert ( not self . item in get_items ( self . level ) ) <EOL> assert ( self . item . location == ( ) ) <EOL> def test_picking_up_not_correct_location ( self ) : <EOL> """<STR_LIT>""" <EOL> self . character . location = ( <NUM_LIT:6> , <NUM_LIT:6> ) <EOL> assert ( self . character . location == ( <NUM_LIT:6> , <NUM_LIT:6> ) ) <EOL> assert ( self . item . location == ( <NUM_LIT:5> , <NUM_LIT:5> ) ) <EOL> pick_up ( self . character , <EOL> self . item ) <EOL> assert ( not self . item in self . character . inventory ) <EOL> assert ( self . item in get_items ( self . level ) ) <EOL> def test_merging_ammunition_in_pickup ( self ) : <EOL> """<STR_LIT>""" <EOL> ammo_1 = ( ItemBuilder ( ) <EOL> . with_name ( '<STR_LIT>' ) <EOL> . with_count ( <NUM_LIT:10> ) <EOL> . build ( ) ) <EOL> ammo_2 = ( ItemBuilder ( ) <EOL> . with_name ( '<STR_LIT>' ) <EOL> . with_count ( <NUM_LIT:20> ) <EOL> . build ( ) ) <EOL> add_item ( self . level , self . character . location , ammo_1 ) <EOL> add_item ( self . level , self . character . location , ammo_2 ) <EOL> pick_up ( self . character , <EOL> ammo_1 ) <EOL> pick_up ( self . character , <EOL> ammo_2 ) <EOL> assert_that ( len ( self . character . inventory ) , is_ ( equal_to ( <NUM_LIT:1> ) ) ) <EOL> item = self . character . inventory [ <NUM_LIT:0> ] <EOL> assert_that ( item . ammunition_data . count , is_ ( equal_to ( <NUM_LIT:30> ) ) ) </s>
