from narval.public import AL_NS

plan = get_plan(memory)

# check plan state
assert_equals(plan.state, 'done')
# check steps'state
assert_equals(plan.elements['step1'].state, 'history')
assert_equals(plan.elements['step2'].state, 'history')
assert_equals(plan.elements['step3'].state, 'done')
# check steps'transitions
assert_equals(plan.elements['t1'].state, 'fired')
assert_equals(plan.elements['t2'].state, 'fired')


# check generated elements
elements = list(get_elements(memory))
assert_equals(len(elements), 4) # two initially in memory + two produced)
produced_elmts = [elmt for elmt in elements if elmt.identity]
assert_equals(len(produced_elmts), 2)
if produced_elmts[0].from_step == 'step2':
    prod1, prod2 = produced_elmts
else:
    prod2, prod1 = produced_elmts
assert not prod1.flag # FIXME: correct ?
assert prod1.identity
assert prod2.flag
assert prod2.identity
