def test_end_week_updates_morale(castle, avatar): '''End_week should update the state of the castle for new week''' castle.morale = 50 castle.buildings['hall'].build() castle.end_week() # only Castle Hall changes morale for now assert castle.morale == 50 + 23
def test_tech_reseted_each_week(castle, avatar): castle.tech = 10 castle.rp = 10 castle.end_week() # there are no buildings built, so tech should be 0 assert castle.tech == 0 assert castle.rp == 0
def test_end_week_sells_equipment(castle, avatar): '''unsused equipment should be sold at end of week''' castle._equipment = 12 assert castle.treasury == 0 castle.end_week() assert castle._equipment == 0 # avatar salary - 5 gold assert castle.treasury == 55
def test_end_week_updates_iron(castle, avatar): '''iron should be produced at iron_per_week rate, unused iron should be sold''' castle.iron_per_week = 11 assert castle._iron == 0 assert castle.treasury == 0 castle.end_week() assert castle._iron == 0 # avatar salary - 5 gold assert castle.treasury == 6
def test_end_week_updates_military(castle, avatar): castle.military = 0 assert castle.military == 0 castle.end_week() assert castle.military == 0 castle.buildings['barracks'].build() castle.end_week() assert castle.buildings['barracks'].troops == 2 assert castle.military == 10
def test_end_week_troops_morale_and_costs(castle, avatar): '''Various troops should change morale and treasury''' castle.morale = 50 castle.treasury = 100 castle.buildings['barracks'].build() castle.end_week() # 50 - 2 * 0.1 assert castle.morale == 49.8 # 100 - avatar salary - soldiers salary assert castle.treasury == 93
def test_avatar_weekly_salary(castle, avatar): castle.treasury = 100 assert avatar.gold == 0 assert castle.treasury == 100 castle.end_week() assert avatar.gold == 5 assert castle.treasury == 95 # check salary while insufficient treasury castle.treasury = 3 avatar.gold = 0 castle.end_week() assert avatar.gold == 3 assert castle.treasury == 0
def test_end_week_spend_rp(castle, avatar, mocker): '''end_week should spend generated research points to current research''' castle.set_research('military_recreation') castle.buildings['library'].build() castle.end_week() assert castle.researches['military_recreation'].rp_spent == 10 assert castle.rp == 0 # complete research on_complete_mock = mocker.patch.object(castle.current_research, 'on_complete') castle.researches['military_recreation'].rp_spent = 97 #~ castle.end_week() castle._spend_research_points() assert castle.researches['military_recreation'].rp_spent == 100 assert castle.researches['military_recreation'].completed assert castle.current_research is None assert castle.rp == 7 assert on_complete_mock.called # check that completed research is added to completed_researches assert castle.completed_researches == ['military_recreation'] castle.end_week() # completed researches should be cleared by "Research report" events, not by castle.end_week assert castle.completed_researches == ['military_recreation']
def test_surface_maintenance_reduction(castle, avatar): '''Maintenance reduction (weekly) should reduce maintenance cost of surface buildings''' # TODO: apply discount only to surface buildings castle = Castle() castle.buildings['library'].build() castle.buildings['kennel'].build() castle.buildings['arena'].build() castle.buildings['summoning'].build() castle.treasury = 100 assert castle.surface_maintenance_reduction == 0 castle.end_week() assert castle.treasury == 67.5 assert castle.surface_maintenance_reduction == 0 # apply discount castle = Castle() castle.buildings['library'].build() castle.buildings['kennel'].build() castle.buildings['arena'].build() castle.buildings['summoning'].build() castle.treasury = 100 castle.surface_maintenance_reduction = 25 castle.end_week() assert castle.treasury == 75.7 assert castle.surface_maintenance_reduction == 0
def test_completed_upgrades(castle, avatar): '''When scheduled upgrade is built, it should be added to list of completed upgrades''' castle.scheduled_upgrades.append('barracks') castle.end_week() assert castle.scheduled_upgrades == [] assert castle.completed_upgrades == ['barracks1'] # completed_upgrades should be cleared next week castle.end_week() assert castle.completed_upgrades == [] # check that the building level is added correctly castle.scheduled_upgrades.append('barracks') castle.end_week() assert castle.completed_upgrades == ['barracks2']
def test_end_week_builds_scheduled_upgrades(castle, avatar): assert castle.scheduled_upgrades == [] castle.scheduled_upgrades = ['tavern'] castle.end_week() assert castle.scheduled_upgrades == [] assert castle.buildings['tavern'].lvl == 1