Skip to content

Commit

Permalink
Added test harness
Browse files Browse the repository at this point in the history
added a basic test harness to make sure Puppitor modules worked across Python 2 and 3 (as it is currently being developed in conjuction with Ren'Py which runs a sandboxed Python 2)
  • Loading branch information
njunius committed Feb 1, 2020
1 parent 1b714fb commit 7754403
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 1 deletion.
64 changes: 64 additions & 0 deletions src/Puppitor_test_harness.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import affecter
import gesture_keys
import animation_structure

test_affecter = affecter.Gesture_Affecter('test_passions_rules.json','./affect_rules/')
test_anim_struct = animation_structure.Animation_Structure(4)
test_affect_vector = affecter.Affect_Vector(test_affecter.affect_rules.keys(), test_affecter.affect_rules)

test_gesture_keys_obj = gesture_keys.Gesture_Interface()

test_gesture_keys_obj.update_possible_states('open_flow', True)
test_gesture_keys_obj.update_possible_states('tempo_up', True)
test_gesture_keys_obj.update_possible_states('tempo_down', True)
test_gesture_keys_obj.update_possible_states('closed_flow', True)
test_gesture_keys_obj.update_possible_states('projected_energy', True)
test_gesture_keys_obj.update_possible_states('pause', True)

print(test_gesture_keys_obj.possible_action_states)
print()

test_gesture_keys_obj.update_actual_states('open_flow', True)
test_affecter.update_affect(test_affect_vector, test_gesture_keys_obj.current_states['actions'], test_gesture_keys_obj.current_states['modifiers'])
print(test_gesture_keys_obj.actual_action_states)
print()
print(test_affect_vector.affects)
test_gesture_keys_obj.update_actual_states('closed_flow', True)
test_affecter.update_affect(test_affect_vector, test_gesture_keys_obj.current_states['actions'], test_gesture_keys_obj.current_states['modifiers'])
print(test_gesture_keys_obj.actual_action_states)
print()
print(test_affect_vector.affects)
print()
test_gesture_keys_obj.update_actual_states('projected_energy', True)
test_affecter.update_affect(test_affect_vector, test_gesture_keys_obj.current_states['actions'], test_gesture_keys_obj.current_states['modifiers'])
print(test_gesture_keys_obj.actual_action_states)
print()
print(test_affect_vector.affects)
print()
test_gesture_keys_obj.update_actual_states('resting', True)
test_affecter.update_affect(test_affect_vector, test_gesture_keys_obj.current_states['actions'], test_gesture_keys_obj.current_states['modifiers'])
print(test_gesture_keys_obj.actual_action_states)
print()
print(test_affect_vector.affects)
print()
test_gesture_keys_obj.update_actual_states('tempo_up', True)
test_affecter.update_affect(test_affect_vector, test_gesture_keys_obj.current_states['actions'], test_gesture_keys_obj.current_states['modifiers'])
print(test_gesture_keys_obj.actual_action_states)
print()
print(test_affect_vector.affects)
print()
test_gesture_keys_obj.update_actual_states('tempo_down', True)
test_affecter.update_affect(test_affect_vector, test_gesture_keys_obj.current_states['actions'], test_gesture_keys_obj.current_states['modifiers'])
print(test_gesture_keys_obj.actual_action_states)
print()
print(test_affect_vector.affects)
print()
test_gesture_keys_obj.update_actual_states('neutral', True)
test_affecter.update_affect(test_affect_vector, test_gesture_keys_obj.current_states['actions'], test_gesture_keys_obj.current_states['modifiers'])
print(test_gesture_keys_obj.actual_action_states)
print()
print(test_affect_vector.affects)
print()

print(test_affecter.get_possible_affects(test_affect_vector))
print(test_affecter.get_prevailing_affect(test_affect_vector))
Binary file added src/__pycache__/affecter.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file added src/__pycache__/gesture_keys.cpython-38.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion src/affecter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, affect_rules_name, affect_rules_directory, affect_floor = 0.0
self.floor_value = affect_floor
self.ceil_value = affect_ceiling
self.equilibrium_action = equilibrium_action
self.current_affect = self.affect_rules.keys()[0] # TODO do something more consistent and robust
self.current_affect = None # changed to None because this value will get updated immediately through the run loop (as long as you call update_affect()

# for use clamping the updated affect values between a given floor_value and ceil_value
def _update_and_clamp_values(self, affect_value, affect_update_value, floor_value, ceil_value):
Expand Down

0 comments on commit 7754403

Please sign in to comment.