def test_can_instantiate_action():
    """
    Tests that Action imports properly and its constructor works.
    """
    assert Action
    action = Action('test', 1)
    assert isinstance(action, Action)
def test_actions_of_different_times_handled_properly(action, long_action):
    """
    This tests to see if this can handle actions of different times
    """
    second_action = Action('action_queue', 1)
    action_queue = ActionQueue()
    action_queue.push(second_action)
    action_queue.push(long_action)
    action_queue.resolve_actions(1)
    assert long_action in action_queue.heap
    assert second_action not in action_queue.heap
def test_multiple_actions_resolve_at_once(action):
    """
    This tests to see if multiple actions can get resolved at once
    """
    action_queue = ActionQueue()
    action_queue.push(action)
    second_action = Action('action_queue', 1)
    action_queue.push(second_action)
    action_queue.resolve_actions(1)
    assert action not in action_queue.heap
    assert second_action not in action_queue.heap
def test_pop_order():
    """
    This tests to see if the queue returns actions in temporal order
    """
    action_queue = ActionQueue()
    rand_order = list(range(0, 10))
    random.shuffle(rand_order)
    print(rand_order)
    for i in rand_order:
        action = Action('test', i)
        action_queue.push(action)
    for i in range(0, 10):
        action = action_queue.pop()
        assert action.time == i
def test_multiple_resolve():
    """
    This tests to see if the queue handles nonadjacent resolution
    """
    action_queue = ActionQueue()
    rand_order = list(range(0, 10))
    random.shuffle(rand_order)
    for i in rand_order:
        action = Action(f'test {i}', i)
        action_queue.push(action)
    assert len(action_queue.heap) == 10
    for time, length in ((2, 7), (4, 5), (8, 1), (10, 0)):
        action_queue.resolve_actions(time)
        assert len(action_queue.heap) == length
def test_action_child_type():
    action = Action(None, 1)
    m_act = MoveAction(None, 1, None, 0, 0, 0)
    assert isinstance(action, Action)
    assert isinstance(m_act, MoveAction)
    assert isinstance(m_act, Action)
Ejemplo n.º 7
0
 def __init__(self, originator:Entity, time_remaining:int, area:Area, dz:int, dx:int, dy:int):
     Action.__init__(self, originator, time_remaining)
     self.area = area
     self.dz = dz
     self.dx = dx
     self.dy = dy
Ejemplo n.º 8
0
def long_action():
    return Action('long', 2)
Ejemplo n.º 9
0
def action():
    return Action('me', 1)