コード例 #1
0
def test_ticket_1509(gui):
	"""
	Crash when quickly switching between tent tabs.
	"""
	yield

	ship = get_player_ship(gui.session)
	gui.select([ship])

	gui.cursor_click(8, 2, 'right')
	while (ship.position.x, ship.position.y) != (8, 2):
		yield

	# Found a settlement
	gui.trigger('overview_trade_ship', 'found_settlement/action/default')
	gui.cursor_click(10, 6, 'left')

	# Build a tent
	gui.trigger('mainhud', 'build/action/default')
	gui.trigger('tab', 'button_01/action/default')
	gui.cursor_click(7, 10, 'left')

	# Select tent
	gui.cursor_click(7, 10, 'left')

	# quickly switch between tabs
	gui.trigger('tab_base', '1/action/default')
	yield
	gui.trigger('tab_base', '0/action/default')
	yield
	gui.trigger('tab_base', '1/action/default')

	yield TestFinished
コード例 #2
0
def test_mission1(gui):
    """Sample mission which requires multiple buildings to win."""

    # Move ship to coast
    ship = get_player_ship(gui.session)
    gui.select([ship])
    move_ship(gui, ship, (7, 3))

    # Build warehouse
    gui.select([ship])
    gui.trigger("overview_trade_ship/found_settlement")
    gui.cursor_click(10, 5, "left")
    assert_goal_reached(gui, "warehouse")

    # Build main square
    gui.trigger("mainhud/build")
    gui.trigger("tab/button_02")
    gui.cursor_click(9, 11, "left")
    assert_goal_reached(gui, "mainsquare")

    # Build fisher
    gui.trigger("tab/button_23")
    gui.cursor_click(7, 7, "left")

    assert_win(gui)
コード例 #3
0
def test_ticket_1369(gui):
	"""
	Ship tab closed when moving away from another player's warehouse after trading.
	"""

	ship = get_player_ship(gui.session)
	gui.select([ship])

	# ally players so they can trade
	world = gui.session.world
	for player in world.players:
		if player is not ship.owner:
			world.diplomacy.add_ally_pair( ship.owner, player )

	# move ship near foreign warehouse and wait for it to arrive
	move_ship(gui, ship, (68, 23))

	# click trade button
	gui.trigger('overview_trade_ship', 'trade')

	# trade widget visible
	assert gui.find(name='buy_sell_goods')

	# move ship away from warehouse
	move_ship(gui, ship, (77, 17))

	# trade widget should not be visible anymore
# For now, the trade widget will stay visible.
#	assert gui.find(name='buy_sell_goods') is None

	# but the ship overview should be
	assert gui.find(name='buy_sell_goods')
コード例 #4
0
def test_traderoute(gui):
	"""Check that a ship's route is configured correctly after setting it up using the GUI."""

	ship = get_player_ship(gui.session)
	gui.select([ship])

	# Create the first settlement
	found_settlement(gui, (36, 34), (38, 39))

	# Give the resources back to the ship
	# Click the trade button
	gui.trigger('overview_trade_ship', 'trade')

	# Get the default amount (50 t, which is more than all available) of everything
	gui.trigger('buy_sell_goods', 'inventory_entry_0')
	gui.trigger('buy_sell_goods', 'inventory_entry_1')
	gui.trigger('buy_sell_goods', 'inventory_entry_2')
	gui.trigger('buy_sell_goods', 'inventory_entry_3')

	# Create the second settlement
	found_settlement(gui, (27, 28), (28, 22))

	# Open the configure trade route widget
	gui.trigger('overview_trade_ship', 'configure_route')

	# The trade route widget is visible
	assert gui.find(name='configure_route')
	route_widget = gui.session.ingame_gui._old_menu.current_tab.route_menu

	assert not ship.route.wait_at_load
	assert not ship.route.wait_at_unload
	assert not ship.route.waypoints

	# Select the first waypoint for the trade route
	event = Mock()
	event.getButton.return_value = fife.MouseEvent.LEFT
	event.map_coords = 38, 39
	route_widget.on_map_click(event, False)

	# Select the other waypoint for the trade route
	event = Mock()
	event.getButton.return_value = fife.MouseEvent.LEFT
	event.map_coords = 28, 22
	route_widget.on_map_click(event, False)

	# Set the resources to be loaded from settlement on the left and the amount
	gui.trigger('configure_route/container_1/slot_0', 'button', mouse='left') # Select the second warehouse's first slot
	gui.trigger('configure_route', 'resource_%d' % RES.FOOD)
	gui.find('configure_route/container_1/slot_0/slider').slide(120)

	# Check if the ship obeys the state of "Wait at load" and "Wait at unload"
	gui.trigger('configure_route', 'wait_at_load')
	gui.trigger('configure_route', 'wait_at_unload')

	assert ship.route.wait_at_load
	assert ship.route.wait_at_unload
	assert len(ship.route.waypoints) == 2
	assert Point(38, 39) in ship.route.waypoints[0]['warehouse'].position
	assert Point(28, 22) in ship.route.waypoints[1]['warehouse'].position
	assert ship.route.waypoints[1]['resource_list'] == {RES.FOOD: 120}
コード例 #5
0
def test_mission1(gui):
	"""Sample mission which requires multiple buildings to win."""

	# Move ship to coast
	ship = get_player_ship(gui.session)
	gui.select([ship])
	move_ship(gui, ship, (7, 3))

	# Build warehouse
	gui.select([ship])
	gui.trigger('overview_trade_ship', 'found_settlement')
	gui.cursor_click(10, 5, 'left')
	assert_goal_reached(gui, 'warehouse')

	# Build main square
	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_02')
	gui.cursor_click(9, 11, 'left')
	assert_goal_reached(gui, 'mainsquare')

	# Build fisher
	gui.trigger('tab', 'button_33')
	gui.cursor_click(7, 7, 'left')

	assert_win(gui)
コード例 #6
0
def test_change_name_empty_not_allowed(gui):
	"""Make sure an object's name can't be changed to some empty string.

	See issue #1978.
	"""
	ship = get_player_ship(gui.session)
	old_name = ship.get_component(NamedComponent).name

	gui.select([ship])

	# try empty name
	def rename_empty():
		gui.find('new_name').write('')
		gui.trigger('change_name_dialog_window', 'okButton')

	with gui.handler(rename_empty):
		gui.trigger('overview_trade_ship', 'name')

	new_name = ship.get_component(NamedComponent).name
	assert old_name == new_name

	# try name with just spaces
	def rename_spaces():
		gui.find('new_name').write('   ')
		gui.trigger('change_name_dialog_window', 'okButton')

	with gui.handler(rename_spaces):
		gui.trigger('overview_trade_ship', 'name')

	new_name = ship.get_component(NamedComponent).name
	assert old_name == new_name
コード例 #7
0
ファイル: test_bugs.py プロジェクト: aedificium/aedificium
def test_ticket_1509(gui):
    """
	Crash when quickly switching between tent tabs.
	"""
    yield

    ship = get_player_ship(gui.session)
    gui.select([ship])

    gui.cursor_click(8, 2, "right")
    while (ship.position.x, ship.position.y) != (8, 2):
        yield

        # Found a settlement
    gui.trigger("overview_trade_ship", "found_settlement")
    gui.cursor_click(10, 6, "left")

    # Build a tent
    gui.trigger("mainhud", "build")
    gui.trigger("tab", "button_01")
    gui.cursor_click(7, 10, "left")

    # Select tent
    gui.cursor_click(7, 10, "left")

    # quickly switch between tabs
    gui.trigger("tab_base", "1")
    yield
    gui.trigger("tab_base", "0")
    yield
    gui.trigger("tab_base", "1")

    yield TestFinished
コード例 #8
0
ファイル: test_bugs.py プロジェクト: perher/unknown-horizons
def test_ticket_1371(gui):
	"""
	Build related tab becomes invisible.

	 * use uninterrupted building (press shift)
	 * click on lumberjack
	 * click on the 'build related' tab
	 * click on the tree
	 * build a tree

     => tab itself is invisible, but buttons for choosing it aren't
	"""
	yield

	ship = get_player_ship(gui.session)
	gui.select([ship])

	gui.cursor_click(59, 1, 'right')
	while (ship.position.x, ship.position.y) != (59, 1):
		yield

	# Found settlement
	gui.trigger('overview_trade_ship', 'found_settlement/action/default')

	gui.cursor_click(56, 3, 'left')

	gui.trigger('mainhud', 'build/action/default')

	# Build lumberjack
	gui.trigger('tab', 'button_5/action/default')
	gui.cursor_click(52, 7, 'left')

	# Select lumberjack
	# TODO selecting should work when clicking on the map
	settlement = gui.session.world.player.settlements[0]
	lumberjack = settlement.get_buildings_by_id(BUILDINGS.LUMBERJACK_CLASS)[0]
	gui.select([lumberjack])

	# Open build related tab
	gui.trigger('tab_base', '1/action/default')

	# Select tree
	gui.trigger('farm_overview_buildrelated', 'build17/action/default')

	# Plant a tree (without uninterrupted building)
	gui.cursor_click(49, 6, 'left')
	assert gui.find(name='farm_overview_buildrelated')

	# Select tree again and plant it with uninterrupted building
	gui.trigger('farm_overview_buildrelated', 'build17/action/default')
	gui.cursor_click(49, 7, 'left', shift=True)

	# Tab should still be there
	assert gui.find(name='farm_overview_buildrelated')

	yield TestFinished
コード例 #9
0
ファイル: test_bugs.py プロジェクト: aedificium/aedificium
def test_ticket_1371(gui):
    """
	Build related tab becomes invisible.

	 * use uninterrupted building (press shift)
	 * click on lumberjack
	 * click on the 'build related' tab
	 * click on the tree
	 * build a tree

     => tab itself is invisible, but buttons for choosing it aren't
	"""
    yield

    ship = get_player_ship(gui.session)
    gui.select([ship])

    gui.cursor_click(59, 1, "right")
    while (ship.position.x, ship.position.y) != (59, 1):
        yield

        # Found settlement
    gui.trigger("overview_trade_ship", "found_settlement")

    gui.cursor_click(56, 3, "left")

    gui.trigger("mainhud", "build")

    # Build lumberjack
    gui.trigger("tab", "button_03")
    gui.cursor_click(52, 7, "left")

    # Select lumberjack
    gui.cursor_click(52, 7, "left")

    # Open build related tab
    gui.trigger("tab_base", "1")

    # Select tree
    gui.trigger("overview_buildrelated", "build17")

    # Plant a tree (without uninterrupted building)
    gui.cursor_click(49, 6, "left")
    assert gui.find(name="overview_buildrelated")

    # Select tree again and plant it with uninterrupted building
    gui.trigger("overview_buildrelated", "build17")
    gui.cursor_click(49, 7, "left", shift=True)

    # Tab should still be there
    assert gui.find(name="overview_buildrelated")

    yield TestFinished
コード例 #10
0
def test_selection_groups(gui):
	"""Check group selection using ctrl-NUM"""

	# Starting a new game assigns player ship to group 1
	ship = get_player_ship(gui.session)
	assert gui.session.selected_instances == set([ship])

	gui.select([ship])

	# make first group
	gui.press_key(gui.Key.NUM_2, ctrl=True)

	gui.select( [] )
	assert not gui.session.selected_instances

	# check group
	gui.press_key(gui.Key.NUM_2)
	assert iter(gui.session.selected_instances).next() is ship

	gui.cursor_click(59, 1, 'right')
	while (ship.position.x, ship.position.y) != (59, 1):
		gui.run()

	# Found settlement
	gui.trigger('overview_trade_ship', 'found_settlement')

	gui.cursor_click(56, 3, 'left')

	gui.trigger('mainhud', 'build')

	wh = gui.session.world.player.settlements[0].warehouse

	gui.select( [wh] )
	gui.press_key(gui.Key.NUM_3, ctrl=True)

	# check group again
	gui.press_key(gui.Key.NUM_2)
	assert len(gui.session.selected_instances) == 1 and \
	       iter(gui.session.selected_instances).next() is ship

	# now other one
	gui.press_key(gui.Key.NUM_3)
	assert len(gui.session.selected_instances) == 1 and \
	       iter(gui.session.selected_instances).next() is wh

	# check group still once again
	gui.press_key(gui.Key.NUM_2)
	assert len(gui.session.selected_instances) == 1 and \
	       iter(gui.session.selected_instances).next() is ship

	# no group
	gui.press_key(gui.Key.NUM_0)
	assert not gui.session.selected_instances
コード例 #11
0
def test_select_ship(gui):
	"""
	Select a ship.
	"""

	assert gui.find('tab_base') is None

	# Find player's ship
	player_ship = get_player_ship(gui.session)

	gui.select([player_ship])
	assert gui.find('overview_trade_ship')
コード例 #12
0
def test_ticket_1948(gui):
	"""Triggers a crash that happens when building a storage tent on the border of the settlement"""
	# Units cannot be selected right now, you need to do it this way. This is almost
	# the same as selecting it with the mouse
	ship = get_player_ship(gui.session)
	gui.select([ship])
	found_settlement(gui, (59, 1), (56, 3))

	# Select storage tent
	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_11')
	# Build storage at the border of the settlement
	gui.cursor_click(37, 20, 'left')
コード例 #13
0
def test_selection_groups(gui):
	"""Check group selection using ctrl-NUM"""
	ship = get_player_ship(gui.session)
	gui.select([ship])

	# make first group
	gui.press_key(gui.Key.NUM_1, ctrl=True)

	gui.select( [] )
	assert len(gui.session.selected_instances) == 0

	# check group
	gui.press_key(gui.Key.NUM_1)
	assert iter(gui.session.selected_instances).next() is ship

	gui.cursor_click(59, 1, 'right')
	while (ship.position.x, ship.position.y) != (59, 1):
		yield

	# Found settlement
	gui.trigger('overview_trade_ship', 'found_settlement/action/default')

	gui.cursor_click(56, 3, 'left')

	gui.trigger('mainhud', 'build/action/default')

	wh = gui.session.world.player.settlements[0].warehouse

	gui.select( [wh] )
	gui.press_key(gui.Key.NUM_2, ctrl=True)

	# check group again
	gui.press_key(gui.Key.NUM_1)
	assert len(gui.session.selected_instances) == 1 and \
	       iter(gui.session.selected_instances).next() is ship

	# now other one
	gui.press_key(gui.Key.NUM_2)
	assert len(gui.session.selected_instances) == 1 and \
	       iter(gui.session.selected_instances).next() is wh

	# check group still once again
	gui.press_key(gui.Key.NUM_1)
	assert len(gui.session.selected_instances) == 1 and \
	       iter(gui.session.selected_instances).next() is ship

	# no group
	gui.press_key(gui.Key.NUM_3)
	assert len(gui.session.selected_instances) == 0

	yield TestFinished
コード例 #14
0
def test_select_ship(gui):
	"""
	Select a ship.
	"""
	yield # test needs to be a generator for now

	assert gui.find('tab_base') is None

	# Find player's ship
	player_ship = get_player_ship(gui.session)

	gui.select([player_ship])
	assert gui.find('overview_trade_ship')

	yield TestFinished
コード例 #15
0
def test_select_ship(gui):
    """
	Select a ship.
	"""

    assert gui.find("overview_trade_ship")

    gui.press_key(gui.Key.NUM_0)
    assert gui.find("tab_base") is None

    # Find player's ship
    player_ship = get_player_ship(gui.session)

    gui.select([player_ship])
    assert gui.find("overview_trade_ship")
コード例 #16
0
def test_ticket_2500(gui):
	"""Game crashes when exiting the game while the building tool is still active."""

	ship = get_player_ship(gui.session)
	gui.select([ship])
	settlement = found_settlement(gui, (13, 64), (17, 62))

	# Select lumberjack
	gui.trigger('mainhud/build')
	gui.trigger('tab/button_03')

	# Quit game via pause menu
	gui.press_key(gui.Key.P)
	def dialog():
		gui.trigger('popup_window/okButton')

	with gui.handler(dialog):
		gui.trigger('menu/quit')
コード例 #17
0
def test_change_name(gui):
	"""Rename a ship."""

	ship = get_player_ship(gui.session)
	old_name = ship.get_component(NamedComponent).name

	assert not gui.find(name='change_name_dialog_window')
	gui.select([ship])
	gui.trigger('overview_trade_ship', 'name')
	assert gui.find(name='change_name_dialog_window')

	gui.find('new_name').write('Dagobert')
	gui.trigger('change_name_dialog_window', 'okButton')
	assert not gui.find(name='change_name_dialog_window')

	new_name = ship.get_component(NamedComponent).name
	assert old_name != new_name
	assert new_name == 'Dagobert'
コード例 #18
0
def test_ticket_1369(gui):
	"""
	Ship tab closed when moving away from another player's warehouse after trading.
	"""
	yield

	ship = get_player_ship(gui.session)
	gui.select([ship])

	# ally players so they can trade
	world = gui.session.world
	for player in world.players:
		if player is not ship.owner:
			world.diplomacy.add_ally_pair( ship.owner, player )

	# move ship near foreign warehouse and wait for it to arrive
	gui.cursor_click(68, 23, 'right')
	while (ship.position.x, ship.position.y) != (68, 23):
		yield

	# click trade button
	gui.trigger('overview_trade_ship', 'trade/action/default')

	# trade widget visible
	assert gui.find(name='buy_sell_goods')

	# move ship away from warehouse
	gui.cursor_click(77, 17, 'right')
	while (ship.position.x, ship.position.y) != (77, 17):
		yield

	# trade widget should not be visible anymore
# For now, the trade widget will stay visible.
#	assert gui.find(name='buy_sell_goods') is None

	# but the ship overview should be
	assert gui.find(name='buy_sell_goods')
#	assert gui.find(name='overview_trade_ship')

	yield TestFinished
コード例 #19
0
def test_ticket_1520(gui):
	"""
	Crash when completing build after outlined/related buildings were removed.
	"""
	yield

	ship = get_player_ship(gui.session)
	gui.select([ship])

	gui.cursor_click(8, 2, 'right')
	while (ship.position.x, ship.position.y) != (8, 2):
		yield

	# Found a settlement
	gui.trigger('overview_trade_ship', 'found_settlement/action/default')
	gui.cursor_click(10, 6, 'left')

	ground_map = gui.session.world.islands[0].ground_map

	# Build a tent
	gui.trigger('mainhud', 'build/action/default')
	gui.trigger('tab', 'button_01/action/default')
	gui.cursor_click(7, 9, 'left')

	assert ground_map[(7, 9)].object.id == BUILDINGS.RESIDENTIAL

	# Start building a mainsquare (not releasing left mouse button)
	gui.trigger('tab', 'button_02/action/default')
	gui.cursor_move(13, 11)
	gui.cursor_press_button(13, 11, 'left')

	# remove tent
	Tear( ground_map[(7, 9)].object ).execute(gui.session)

	# release mouse button, finish build
	gui.cursor_release_button(13, 11, 'left')

	yield TestFinished
コード例 #20
0
def test_pavilion_build_crash_built_via_settler_related_tab(gui):
	"""
	"""
	yield

	ship = get_player_ship(gui.session)
	gui.select([ship])

	gui.cursor_click(59, 1, 'right')
	while (ship.position.x, ship.position.y) != (59, 1):
		yield

	# Found settlement
	gui.trigger('overview_trade_ship', 'found_settlement/action/default')

	gui.cursor_click(56, 3, 'left')

	gui.trigger('mainhud', 'build/action/default')

	# Build settler
	gui.trigger('tab', 'button_01/action/default')
	gui.cursor_click(52, 7, 'left')

	# Select settler
	gui.cursor_click(52, 7, 'left')

	# Open build related tab
	gui.trigger('tab_base', '1/action/default')

	# Select pavilion
	gui.trigger('overview_buildrelated', 'build5/action/default')

	# Plant it
	gui.cursor_click(49, 6, 'left')

	# if we survive until here, the bug hasn't happened
	yield TestFinished
コード例 #21
0
ファイル: test_bugs.py プロジェクト: aedificium/aedificium
def test_pavilion_build_crash_built_via_settler_related_tab(gui):
    """
	"""
    yield

    ship = get_player_ship(gui.session)
    gui.select([ship])

    gui.cursor_click(59, 1, "right")
    while (ship.position.x, ship.position.y) != (59, 1):
        yield

        # Found settlement
    gui.trigger("overview_trade_ship", "found_settlement")

    gui.cursor_click(56, 3, "left")

    gui.trigger("mainhud", "build")

    # Build settler
    gui.trigger("tab", "button_01")
    gui.cursor_click(52, 7, "left")

    # Select settler
    gui.cursor_click(52, 7, "left")

    # Open build related tab
    gui.trigger("tab_base", "1")

    # Select pavilion
    gui.trigger("overview_buildrelated", "build5")

    # Plant it
    gui.cursor_click(49, 6, "left")

    # if we survive until here, the bug hasn't happened
    yield TestFinished
コード例 #22
0
def test_ticket_2475(gui):
	"""Game crashes when two resources are produced in the same tick and the production
	finished icon is about to be shown."""

	# speed up animation to trigger bug earlier
	gui.session.ingame_gui.production_finished_icon_manager.animation_duration = 1

	ship = get_player_ship(gui.session)
	gui.select([ship])
	settlement = found_settlement(gui, (13, 64), (17, 62))

	# Place a lumberjack
	gui.trigger('mainhud/build')
	gui.trigger('tab/button_03')
	gui.cursor_click(18, 57, 'left', shift=True)

	lumberjack = settlement.buildings_by_id[BUILDINGS.LUMBERJACK][0]
	storage = lumberjack.get_component(StorageComponent)
	producer = lumberjack.get_component(Producer)

	storage.inventory.alter(RES.BOARDS, 5)

	producer.on_production_finished({RES.BOARDS: 1})
	producer.on_production_finished({RES.BOARDS: 1})
コード例 #23
0
def test_found_settlement(gui):
	"""
	Found a settlement.
	"""
	yield # test needs to be a generator for now

	player = gui.session.world.player
	target = (68, 10)
	gui.session.view.center(*target)

	assert len(player.settlements) == 0

	ship = get_player_ship(gui.session)
	Act(ship, *target)(player)

	# wait until ship arrives
	while (ship.position.x, ship.position.y) != target:
		yield

	gui.select([ship])
	gui.trigger('overview_trade_ship', 'found_settlement/action/default')

	assert isinstance(gui.cursor, BuildingTool)
	gui.cursor_move(64, 12)
	gui.cursor_click(64, 12, 'left')

	assert isinstance(gui.cursor, CursorTool)
	assert len(player.settlements) == 1

	# activate the build menu
	ground_map = gui.session.world.islands[0].ground_map
	gui.trigger('mainhud', 'build/action/default')

	# build a lumberjack
	gui.trigger('tab', 'button_03/action/default')
	gui.cursor_click(55, 5, 'left')
	assert(ground_map[(55, 5)].object.id == BUILDINGS.LUMBERJACK)

	# build a storage
	gui.trigger('tab', 'button_11/action/default')
	gui.cursor_click(55, 15, 'left')
	storage = ground_map[(55, 15)].object
	assert(storage.id == BUILDINGS.STORAGE)

	# connect the lumberjack and storage using a road
	gui.trigger('tab', 'button_21/action/default')
	for y in xrange(7, 15):
		gui.cursor_click(55, y, 'left')
		assert(ground_map[(55, y)].object.id == BUILDINGS.TRAIL)
	gui.cursor_click(55, y, 'right')

	# select the storage
	gui.cursor_click(55, 15, 'left')
	assert gui.find('warehouse_and_storage_overview')
	collectors = storage.get_component(CollectingComponent).get_local_collectors()

	while True:
		if any(collector.state is Collector.states.moving_to_target for collector in collectors):
			break
		yield

	# remove the storage, trigger ticket 1441
	gui.press_key(gui.Key.DELETE)
	start = time.time()
	# wait 0.5 seconds
	while time.time() - start < 0.5:
		yield
	assert ground_map[(55, 15)].object is None

	yield TestFinished
コード例 #24
0
def test_trade(gui):
	"""
	"""

	ship = get_player_ship(gui.session)
	gui.select([ship])

	# ally players so they can trade
	world = gui.session.world
	for player in world.players:
		if player is not ship.owner:
			world.diplomacy.add_ally_pair( ship.owner, player )

	# move ship near foreign warehouse and wait for it to arrive
	move_ship(gui, ship, (68, 23))

	# click trade button
	gui.trigger('overview_trade_ship', 'trade')

	# trade widget visible
	assert gui.find(name='buy_sell_goods')

	ship_inv = ship.get_component(StorageComponent).inventory
	settlement = gui.session.world.islands[0].settlements[0]
	settlement_inv = settlement.get_component(StorageComponent).inventory

	# transfer 1 t
	gui.trigger('buy_sell_goods', 'size_1')

	old_ship_value = ship_inv[RES.BOARDS]
	old_settlement_value = settlement_inv[RES.BOARDS]

	# of boards (will be bought)
	gui.trigger('buy_sell_goods', 'inventory_entry_0')

	assert old_settlement_value + 1 == settlement_inv[RES.BOARDS]
	assert old_ship_value - 1 == ship_inv[RES.BOARDS]

	old_ship_value = ship_inv[RES.CANNON]
	old_settlement_value = settlement_inv[RES.CANNON]

	# now cannons (won't be bought)
	gui.trigger('buy_sell_goods', 'inventory_entry_3')

	assert old_settlement_value == settlement_inv[RES.CANNON]
	assert old_ship_value == ship_inv[RES.CANNON]

	# the ai has to want more boards
	trade_post = settlement.get_component(TradePostComponent)
	assert settlement_inv[RES.BOARDS] < trade_post.slots[trade_post.buy_list[RES.BOARDS]].limit

	# transfer 50 t of boards
	gui.trigger('buy_sell_goods', 'size_5')
	gui.trigger('buy_sell_goods', 'inventory_entry_0')

	# now it has enough
	assert settlement_inv[RES.BOARDS] == trade_post.slots[trade_post.buy_list[RES.BOARDS]].limit

	old_ship_value = ship_inv[RES.BOARDS]

	# so another click won't do anything
	gui.trigger('buy_sell_goods', 'inventory_entry_0')

	assert old_ship_value == ship_inv[RES.BOARDS]

	# no matter how small the amount
	gui.trigger('buy_sell_goods', 'size_1')
	gui.trigger('buy_sell_goods', 'inventory_entry_0')

	assert old_ship_value == ship_inv[RES.BOARDS]

	# make room on ship inventory
	ship_inv.alter(RES.BOARDS, - ship_inv[RES.BOARDS])

	# test sell now, give settlement something to sell
	SetTradeSlot(trade_post, 2, RES.ALVEARIES, True, 5)(settlement.owner)
	settlement.get_component(StorageComponent).inventory.alter(RES.ALVEARIES, 10)

	# this gives us 5 alevaries
	assert ship_inv[RES.ALVEARIES] == 0
	# first transfer one
	gui.trigger('buy_sell_goods', 'size_1')
	gui.trigger('buy_sell_goods', 'buy_sell_inventory_True_entry_1')

	print ship_inv[RES.ALVEARIES]
	assert ship_inv[RES.ALVEARIES] == 1
	assert settlement_inv[RES.ALVEARIES] == 9

	# now transfer 5, should actually transfer 4
	gui.trigger('buy_sell_goods', 'size_2')
	gui.trigger('buy_sell_goods', 'buy_sell_inventory_True_entry_1')
	assert ship_inv[RES.ALVEARIES] == 5
	assert settlement_inv[RES.ALVEARIES] == 5
コード例 #25
0
def test_buildingtool(gui):
    """
	Trigger different buildingtool highlights
	"""

    ship = get_player_ship(gui.session)

    gui.select([ship])

    # Move ship
    gui.cursor_click(57, 0, 'right')

    # Wait for ship to arrive
    while (ship.position.x, ship.position.y) != (57, 0):
        gui.run()

    gui.trigger('overview_trade_ship', 'found_settlement')

    def build_at(target):
        # build while moving around cursor beforehand
        OFFSETS = [0, 1, -1, 2, -2, 5, -5, 20,
                   -20]  # don't add more, takes long enough already
        for off_x, off_y in itertools.product(OFFSETS, repeat=2):
            # will trigger preview_build of BuildingTool
            gui.cursor_move(target[0] + off_x, target[1] + off_y)
        gui.cursor_click(target[0], target[1], 'left')

    # Place warehouse
    build_at((56, 3))
    assert gui.session.world.settlements

    # Select buildmenu
    gui.trigger('mainhud', 'build')

    # Select fisher
    gui.trigger('tab', 'button_33')

    # Place fisher
    build_at((52, 3))

    # Build lumberjack
    gui.trigger('tab', 'button_03')
    build_at((52, 6))

    # Build main square
    gui.trigger('tab', 'button_02')
    build_at((53, 11))

    # Select path
    gui.trigger('tab', 'button_21')

    # Build some paths
    for i in xrange(6, 13):
        build_at((57, i))
    gui.cursor_click(54, 7, 'right')  # cancel

    # Build a tent
    gui.trigger('tab', 'button_01')
    build_at((58, 7))

    # Select pavilion (tent highlights)
    gui.trigger('tab', 'button_12')
    build_at((58, 5))

    # Build a tent (pavilion highlights)
    gui.trigger('tab', 'button_01')
    build_at((58, 9))
コード例 #26
0
ファイル: test_build.py プロジェクト: aedificium/aedificium
def test_found_settlement(gui):
    """
	Found a settlement.
	"""
    yield  # test needs to be a generator for now

    player = gui.session.world.player
    target = (68, 10)
    gui.session.view.center(*target)

    assert not player.settlements

    ship = get_player_ship(gui.session)
    Act(ship, *target)(player)

    # wait until ship arrives
    while (ship.position.x, ship.position.y) != target:
        yield

    gui.select([ship])
    gui.trigger("overview_trade_ship", "found_settlement")

    assert isinstance(gui.cursor, BuildingTool)
    gui.cursor_move(64, 12)
    gui.cursor_click(64, 12, "left")

    assert isinstance(gui.cursor, CursorTool)
    assert len(player.settlements) == 1

    # activate the build menu
    ground_map = gui.session.world.islands[0].ground_map
    gui.trigger("mainhud", "build")

    # build a lumberjack
    gui.trigger("tab", "button_03")
    gui.cursor_click(55, 5, "left")
    assert ground_map[(55, 5)].object.id == BUILDINGS.LUMBERJACK

    # build a storage
    gui.trigger("tab", "button_11")
    gui.cursor_click(55, 15, "left")
    storage = ground_map[(55, 15)].object
    assert storage.id == BUILDINGS.STORAGE

    # connect the lumberjack and storage using a road
    gui.trigger("tab", "button_21")
    for y in xrange(7, 15):
        gui.cursor_click(55, y, "left")
        assert ground_map[(55, y)].object.id == BUILDINGS.TRAIL
    gui.cursor_click(55, y, "right")

    # select the storage
    gui.cursor_click(55, 15, "left")
    assert gui.find("warehouse_and_storage_overview")
    collectors = storage.get_component(CollectingComponent).get_local_collectors()

    while True:
        if any(collector.state is Collector.states.moving_to_target for collector in collectors):
            break
        yield

        # remove the storage, trigger ticket 1441
    gui.press_key(gui.Key.DELETE)
    start = time.time()
    # wait 0.5 seconds
    while time.time() - start < 0.5:
        yield
    assert ground_map[(55, 15)].object is None

    # open build menu again
    gui.trigger("mainhud", "build")

    # build a fisher
    gui.trigger("tab", "button_33")
    gui.cursor_click(60, 4, "left")
    fisher = ground_map[(60, 4)].object
    assert fisher.id == BUILDINGS.FISHER

    # connect the lumberjack and fisher using a road
    gui.trigger("tab", "button_21")
    for x in xrange(57, 60):
        gui.cursor_click(x, 5, "left")
        assert ground_map[(x, 5)].object.id == BUILDINGS.TRAIL
    gui.cursor_click(x, 5, "right")

    # trigger ticket 1767
    # build a signal fire
    gui.trigger("tab", "button_22")
    gui.cursor_click(58, 5, "left")
    gui.cursor_click(58, 4, "left")

    yield TestFinished
コード例 #27
0
def test_tutorial(gui):
    """Test the tutorial scenario."""

    # FIXME disable disasters (this should be an option for a scenario)
    gui.session.world.disaster_manager.disabled = True

    def assert_progress(progress):
        wait_and_close_logbook(gui)
        assert var_eq(gui.session, "tutorial_progress", progress)

        # Tutorial start

    assert_progress(16)

    # Goal: Build warehouse
    ship = get_player_ship(gui.session)
    move_ship(ship, (11, 1))

    gui.select([ship])
    gui.trigger("overview_trade_ship", "found_settlement")
    gui.cursor_click(11, 6, "left")

    # Goal: Build a lumberjack
    assert_progress(19)

    # lumberjack
    gui.trigger("mainhud", "build")
    gui.trigger("tab", "button_03")
    gui.cursor_click(8, 10, "left")

    # roads
    gui.trigger("tab", "button_21")
    gui.cursor_multi_click((10, 8), (10, 9), (10, 10))

    # Goal: Build hunter and fisher
    assert_progress(22)

    # fisher
    gui.trigger("tab", "button_33")
    gui.cursor_click(13, 6, "left")

    # hunter
    gui.trigger("tab", "button_23")
    gui.cursor_click(8, 8, "left")

    # Goal: Mainsquare
    assert_progress(25)

    gui.trigger("tab", "button_02")
    gui.cursor_click(15, 18, "left")

    # Goal: first tent
    assert_progress(28)

    # roads
    gui.trigger("tab", "button_21")
    gui.cursor_multi_click((13, 15), (14, 15), (16, 15), (17, 15), (18, 15), (19, 15), (20, 15))

    # tent
    gui.trigger("tab", "button_01")
    gui.cursor_click(13, 13, "left")

    # Goal: 4 tents
    assert_progress(31)

    gui.trigger("tab", "button_01")
    gui.cursor_multi_click((15, 13), (17, 13), (19, 13))

    # Goal: Build a signal fire
    assert_progress(34)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 5):
        gui.run()

    gui.trigger("tab", "button_22")
    gui.cursor_click(9, 5, "left")

    # Goal: Trading
    assert_progress(37)

    # TODO do this with the gui (needs named buttons and a way to control the slider)
    player = gui.session.world.player
    tradepost = player.settlements[0].get_component(TradePostComponent)
    AddToBuyList(tradepost, RES.TOOLS, 30)(player)

    # Goal: Pavilion
    assert_progress(40)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 5):
        gui.run()

    gui.trigger("tab", "button_12")
    gui.cursor_click(19, 16, "left")

    # Goal: Next tier
    assert_progress(43)

    # TODO adjust settler taxes

    # wait until settlers upgraded
    while not settler_level_greater(gui.session, TIER.SAILORS):
        gui.run()

        # Goal: Farm
    assert_progress(46)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 10):
        gui.run()

    gui.trigger("tab_base", "1")  # FIXME this sometimes fails
    gui.trigger("tab", "button_02")
    gui.cursor_click(25, 12, "left")

    # Goal: Fields
    assert_progress(49)

    gui.trigger("tab_base", "1")

    # potato
    gui.trigger("tab", "button_12")
    gui.cursor_click(23, 11, "left")

    # pasture
    gui.trigger("tab", "button_22")
    gui.cursor_click(21, 10, "left")

    # Goal: Storage
    assert_progress(52)

    # remove a tree to connect to farm
    gui.trigger("mainhud", "destroy_tool")
    gui.cursor_click(21, 15, "left")

    # roads
    gui.trigger("mainhud", "build")
    gui.trigger("tab_base", "0")
    gui.trigger("tab", "button_21")
    gui.cursor_multi_click((21, 15), (22, 15), (23, 15), (24, 15), (24, 14))

    # storage tent
    gui.trigger("tab", "button_11")
    gui.cursor_click(21, 16, "left")

    # Goal: Weaver
    assert_progress(55)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 10):
        gui.run()

    gui.trigger("tab_base", "1")
    gui.trigger("tab", "button_21")
    gui.cursor_click(25, 14, "left")

    # Goal: 50 inhabitants, positive balance
    assert_progress(58)

    # more potatoe fields
    gui.trigger("tab_base", "1")
    gui.trigger("tab", "button_12")
    gui.cursor_multi_click((24, 9), (27, 8), (27, 11))

    # lumberjack (more wood for upgrades)
    gui.trigger("tab_base", "0")
    gui.trigger("tab", "button_03")
    gui.cursor_click(19, 18, "left")

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 39):
        gui.run()

        # tents
    gui.trigger("tab", "button_01")
    gui.cursor_multi_click(
        (11, 14), (11, 15), (12, 17), (11, 20), (12, 22), (14, 22), (16, 22), (18, 22), (19, 20), (22, 15)
    )

    # Goal: Won
    assert_progress(61)

    assert_win(gui)
コード例 #28
0
def test_buildingtool(gui):
	"""
	Trigger different buildingtool highlights
	"""

	ship = get_player_ship(gui.session)

	gui.select([ship])

	# Move ship
	gui.cursor_click(57, 0, 'right')

	# Wait for ship to arrive
	while (ship.position.x, ship.position.y) != (57, 0):
		gui.run()

	gui.trigger('overview_trade_ship', 'found_settlement')

	def build_at(target):
		# build while moving around cursor beforehand
		OFFSETS = [ 0, 1, -1, 2, -2, 5, -5, 20, -20 ] # don't add more, takes long enough already
		for off_x, off_y in itertools.product( OFFSETS, repeat=2 ):
			# will trigger preview_build of BuildingTool
			gui.cursor_move( target[0]+off_x, target[1]+off_y )
		gui.cursor_click(target[0], target[1], 'left')

	# Place warehouse
	build_at( (56, 3) )
	assert gui.session.world.settlements

	# Select buildmenu
	gui.trigger('mainhud', 'build')

	# Select fisher
	gui.trigger('tab', 'button_33')

	# Place fisher
	build_at( (52, 3) )


	# Build lumberjack
	gui.trigger('tab', 'button_03')
	build_at( (52, 6) )

	# Build main square
	gui.trigger('tab', 'button_02')
	build_at( (53, 11) )

	# Select path
	gui.trigger('tab', 'button_21')

	# Build some paths
	for i in xrange(6, 13):
		build_at( (57, i) )
	gui.cursor_click(54, 7, 'right') # cancel

	# Build a tent
	gui.trigger('tab', 'button_01')
	build_at( (58, 7) )

	# Select pavilion (tent highlights)
	gui.trigger('tab', 'button_12')
	build_at( (58, 5) )

	# Build a tent (pavilion highlights)
	gui.trigger('tab', 'button_01')
	build_at( (58, 9) )
コード例 #29
0
def test_build_a_settlement(gui):
	"""
	Build a settlement. Generated with gui logger.
	"""

	ship = get_player_ship(gui.session)

	gui.select([ship])

	# Move ship
	gui.cursor_click(57, 0, 'right')

	# Wait for ship to arrive
	while (ship.position.x, ship.position.y) != (57, 0):
		gui.run()

	gui.trigger('overview_trade_ship', 'found_settlement')

	# Place warehouse
	gui.cursor_click(56, 3, 'left')
	assert gui.session.world.settlements

	# Select buildmenu
	gui.trigger('mainhud', 'build')

	# Select fisher
	gui.trigger('tab', 'button_33')

	# Place fisher
	gui.cursor_click(52, 3, 'left')

	# Select path
	gui.trigger('tab', 'button_21')

	# Build some paths
	# Has to be one by one, no mouse drag support yet
	gui.cursor_click(52, 5, 'left')
	gui.cursor_click(53, 5, 'left')
	gui.cursor_click(54, 5, 'left')
	gui.cursor_click(55, 5, 'left')
	gui.cursor_click(56, 5, 'left')
	gui.cursor_click(57, 5, 'left')
	gui.cursor_click(54, 7, 'right')	# cancel

	# Build lumberjack
	gui.trigger('tab', 'button_03')
	gui.cursor_click(52, 6, 'left')

	# Build main square
	gui.trigger('tab', 'button_02')
	gui.cursor_click(53, 11, 'left')

	# Select path
	gui.trigger('tab', 'button_21')

	# Build some paths
	gui.cursor_click(57, 6, 'left')
	gui.cursor_click(57, 7, 'left')
	gui.cursor_click(57, 8, 'left')
	gui.cursor_click(57, 9, 'left')
	gui.cursor_click(57, 10, 'left')
	gui.cursor_click(57, 11, 'left')
	gui.cursor_click(57, 12, 'left')
	gui.cursor_click(57, 13, 'right')	# cancel

	# Build a tent
	gui.trigger('tab', 'button_01')
	gui.cursor_click(58, 9, 'left')

	# Build a tent
	gui.trigger('tab', 'button_01')
	gui.cursor_click(58, 7, 'left')

	# Build a tent
	gui.trigger('tab', 'button_01')
	gui.cursor_click(58, 5, 'left')
コード例 #30
0
def test_tutorial(gui):
	"""Test the tutorial scenario."""

	# FIXME disable disasters (this should be an option for a scenario)
	gui.session.world.disaster_manager.disabled = True

	def assert_progress(progress):
		wait_and_close_logbook(gui)
		assert var_eq(gui.session, 'tutorial_progress', progress)

	# Tutorial start
	assert_progress(16)

	# Goal: Build warehouse
	ship = get_player_ship(gui.session)
	gui.select([ship])
	move_ship(gui, ship, (11, 1))

	# Save and reload scenario (1/3)
	saveload(gui)

	gui.trigger('overview_trade_ship', 'found_settlement')
	gui.cursor_click(11, 6, 'left')

	# Goal: Build a lumberjack
	assert_progress(19)

	# lumberjack (2)
	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_03')
	gui.cursor_click(8, 10, 'left', shift=True)
	gui.cursor_click(13, 10, 'left')
	gui.cursor_click(13, 10, 'right')

	# plant some extra trees around the lumberjacks
	gui.trigger('tab', 'button_13')
	gui.cursor_drag((6, 13), (15, 8), 'left')

	# roads (no dragging to trigger the 'you can drag roads' hint)
	gui.trigger('tab', 'button_21')
	gui.cursor_multi_click((10, 8), (10, 9), (10, 10), (11, 10))

	# Goal: Build hunter and fisher
	assert_progress(22)

	# fisher
	gui.trigger('tab', 'button_33')
	gui.cursor_click(13, 6, 'left')

	# hunter
	gui.trigger('tab', 'button_23')
	gui.cursor_click(8, 8, 'left')

	# Goal: Mainsquare
	assert_progress(25)

	gui.trigger('tab', 'button_02')
	gui.cursor_click(15, 18, 'left')

	# Goal: first tent
	assert_progress(28)

	# roads
	gui.trigger('tab', 'button_21')
	gui.cursor_drag((13, 15), (20, 15), 'left')
	gui.cursor_click(20, 15, 'right')

	# tent
	gui.trigger('tab', 'button_01')
	gui.cursor_click(13, 13, 'left')

	# Goal: 4 tents
	assert_progress(31)

	gui.trigger('tab', 'button_01')
	gui.cursor_multi_click((15, 13), (17, 13), (19, 13))

	# Goal: Build a signal fire
	assert_progress(34)

	# Save and reload scenario (2/3)
	saveload(gui)

	# Open build menu again (it is not reloaded, unlike selected instances)
	gui.trigger('mainhud', 'build')
	gui.trigger('tab_base', '0')

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 5):
		gui.run()

	gui.trigger('tab', 'button_22')
	gui.cursor_click(9, 5, 'left')

	# Goal: Trading
	assert_progress(37)

	# Buy tools from the trader (put the resource on the buy list)
	gui.cursor_click(11, 6, 'left')
	gui.trigger('tab_base', '2')
	gui.trigger('buysellmenu/slot_0', 'button', mouse='left')
	gui.trigger('select_trade_resource', 'resource_%d' % RES.TOOLS)
	gui.find('buysellmenu/slot_0/slider').slide(30)

	# Goal: Pavilion
	assert_progress(40)

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 5):
		gui.run()

	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_12')
	gui.cursor_click(19, 16, 'left')

	# Goal: Next tier
	assert_progress(43)

	# Adjust settler taxes (using mainsquare)
	gui.cursor_click(16, 18, 'left')
	gui.trigger('tab_base', '1')
	gui.find('tax_slider').slide(0)
	gui.trigger('mainhud', 'build')

	# wait until settlers upgraded
	while not settler_level_greater(gui.session, TIER.SAILORS):
		gui.run()

	# Goal: Farm
	assert_progress(46)

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 10):
		gui.run()

	gui.trigger('tab_base', '1') # FIXME this sometimes fails
	gui.trigger('tab', 'button_02')
	gui.cursor_click(25, 12, 'left')

	# Goal: Fields
	assert_progress(49)

	gui.trigger('tab_base', '1')

	# potato
	gui.trigger('tab', 'button_12')
	gui.cursor_click(23, 11, 'left')

	# Save and reload scenario (3/3)
	saveload(gui)

	# Open build menu again
	gui.trigger('mainhud', 'build')
	gui.trigger('tab_base', '1')

	# pasture
	gui.trigger('tab', 'button_22')
	gui.cursor_click(21, 10, 'left')

	# Goal: Storage
	assert_progress(52)

	# remove a tree to connect to farm
	gui.trigger('mainhud', 'destroy_tool')
	gui.cursor_click(21, 15, 'left')

	# roads
	gui.trigger('mainhud', 'build')
	gui.trigger('tab_base', '0')
	gui.trigger('tab', 'button_21')
	gui.cursor_drag((21, 15), (24, 14), 'left')
	gui.cursor_click(24, 14, 'right')
	# back of mainsquare
	gui.trigger('tab', 'button_21')
	gui.cursor_drag((13, 22), (20, 22), 'left')
	gui.cursor_click(20, 22, 'right')

	# storage tent
	gui.trigger('tab', 'button_11')
	gui.cursor_click(21, 16, 'left')

	# Goal: Weaver
	assert_progress(55)

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 10):
		gui.run()

	gui.trigger('tab_base', '1')
	gui.trigger('tab', 'button_21')
	gui.cursor_click(25, 14, 'left')

	# Goal: 50 inhabitants, positive balance
	assert_progress(58)

	# more potato fields
	gui.trigger('tab_base', '1')
	gui.trigger('tab', 'button_12')
	gui.cursor_multi_click((24, 9), (27, 8), (27, 11))

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 39):
		gui.run()

	# tents
	gui.trigger('tab_base', '0')
	gui.trigger('tab', 'button_01')
	gui.cursor_multi_click(
		(11, 14), (11, 15), (12, 17), (11, 20), (11, 22),
		(13, 23), (15, 23), (17, 23), (19, 23),
		(19, 20), (22, 15), (19, 18), (20, 21)
	)

	# Goal: Won
	assert_progress(61)

	assert_win(gui)
コード例 #31
0
ファイル: test_trade.py プロジェクト: hoffi/unknown-horizons
def test_trade(gui):
	"""
	"""
	yield

	ship = get_player_ship(gui.session)
	gui.select([ship])

	# ally players so they can trade
	world = gui.session.world
	for player in world.players:
		if player is not ship.owner:
			world.diplomacy.add_ally_pair( ship.owner, player )

	# move ship near foreign warehouse and wait for it to arrive
	gui.cursor_click(68, 23, 'right')
	while (ship.position.x, ship.position.y) != (68, 23):
		yield

	# click trade button
	gui.trigger('overview_trade_ship', 'trade/action/default')

	# trade widget visible
	assert gui.find(name='buy_sell_goods')

	ship_inv = ship.get_component(StorageComponent).inventory
	settlement = gui.session.world.islands[0].settlements[0]
	settlement_inv = settlement.get_component(StorageComponent).inventory

	# transfer 1 t
	gui.trigger('buy_sell_goods', 'size_1/action/default')

	old_ship_value = ship_inv[RES.BOARDS]
	old_settlement_value = settlement_inv[RES.BOARDS]

	# of boards (will be bought)
	gui.trigger('buy_sell_goods', 'inventory_entry_0/action/default')

	assert old_settlement_value + 1 == settlement_inv[RES.BOARDS]
	assert old_ship_value - 1 == ship_inv[RES.BOARDS]

	old_ship_value = ship_inv[RES.CANNON]
	old_settlement_value = settlement_inv[RES.CANNON]

	# now cannons (won't be bought)
	gui.trigger('buy_sell_goods', 'inventory_entry_3/action/default')

	assert old_settlement_value == settlement_inv[RES.CANNON]
	assert old_ship_value == ship_inv[RES.CANNON]

	# the ai has to want more boards
	assert settlement_inv[RES.BOARDS] < settlement.get_component(TradePostComponent).buy_list[RES.BOARDS]

	# transfer 50 t of boards
	gui.trigger('buy_sell_goods', 'size_5/action/default')
	gui.trigger('buy_sell_goods', 'inventory_entry_0/action/default')

	# now it has enough
	assert settlement_inv[RES.BOARDS] == settlement.get_component(TradePostComponent).buy_list[RES.BOARDS]

	old_ship_value = ship_inv[RES.BOARDS]

	# so another click won't do anything
	gui.trigger('buy_sell_goods', 'inventory_entry_0/action/default')

	assert old_ship_value == ship_inv[RES.BOARDS]

	# no matter how small the amount
	gui.trigger('buy_sell_goods', 'size_1/action/default')
	gui.trigger('buy_sell_goods', 'inventory_entry_0/action/default')

	assert old_ship_value == ship_inv[RES.BOARDS]

	# make room on ship inventory
	ship_inv.alter(RES.BOARDS, - ship_inv[RES.BOARDS])

	# test sell now, give settlement something to sell
	settlement.get_component(TradePostComponent).sell_list[RES.ALVEARIES] = 5
	settlement.get_component(StorageComponent).inventory.alter(RES.ALVEARIES, 10)

	# this gives us 5 alevaries
	assert ship_inv[RES.ALVEARIES] == 0
	# first transfer one
	gui.trigger('buy_sell_goods', 'size_1/action/default')
	gui.trigger('buy_sell_goods', 'buy_sell_inventory_True_entry_1/action/default')

	print ship_inv[RES.ALVEARIES]
	assert ship_inv[RES.ALVEARIES] == 1
	assert settlement_inv[RES.ALVEARIES] == 9

	# now transfer 5, should actually transfer 4
	gui.trigger('buy_sell_goods', 'size_2/action/default')
	gui.trigger('buy_sell_goods', 'buy_sell_inventory_True_entry_1/action/default')
	assert ship_inv[RES.ALVEARIES] == 5
	assert settlement_inv[RES.ALVEARIES] == 5

	yield TestFinished