def test_10(self): #retrieve persisted function pf=AestheticFunctionAO.get_function(self.func1) pf2=AestheticFunctionAO.get_function(self.func2) #perform the and operation pf3 = pf.union(pf2) #check the result assert pf3.interactivity.issubset(self.interbehunion) and pf3.interactivity.issuperset(self.interbehunion) assert pf3.ludic.issubset(self.ludbehunion) and pf3.ludic.issuperset(self.ludbehunion) assert pf3.external_id is None #try to persist (must fail!) #trying to assign a name in a language not supported by the system self.assertRaises(RuntimeError, pf3.save)
def test_03(self): """ Creating a function must start the behaviors and persist them """ #creates the function... pf2=AestheticFunctionAO.create_function() #now, checks the persistence of each behavior l_intbeh=pf2.interactivity l_ludbeh=pf2.ludic assert pf2.elements is not None assert pf2.external_id is not None assert len(pf2.external_id) > 0 assert l_intbeh is not None assert l_ludbeh is not None assert l_intbeh.external_id is not None assert len(l_intbeh.external_id) > 0 assert l_ludbeh.external_id is not None assert len(l_ludbeh.external_id) > 0 pf2db=AestheticFunctionDB.objects.filter(external_id=pf2.external_id).first() # pylint: disable=no-member assert pf2db is not None assert pf2db.external_id == pf2.external_id self.__class__.func2=pf2.external_id ibdb=BehaviorDB.objects.filter(external_id=l_intbeh.external_id).first() # pylint: disable=no-member assert ibdb is not None assert ibdb.external_id == l_intbeh.external_id lbdb=BehaviorDB.objects.filter(external_id=l_ludbeh.external_id).first() # pylint: disable=no-member assert lbdb is not None assert lbdb.external_id == l_ludbeh.external_id
def test_04(self): #add the elements to the aesthetic function, persist and check #add the elements to each behavior pf2=AestheticFunctionAO.get_function(self.func2) for elt in self.inter1: pf2.add_interactivity_element(self.elAO[elt]) for elt in self.ludi1: pf2.add_ludic_element(self.elAO[elt]) #check each behavior (the hashes must be the same) assert pf2.interactivity.issubset(self.interbeh2) and pf2.interactivity.issuperset(self.interbeh2) assert pf2.ludic.issubset(self.ludbeh2) and pf2.ludic.issuperset(self.ludbeh2) #persist pf2.save() #check persistence information l_intbeh=pf2.interactivity l_ludbeh=pf2.ludic idb=BehaviorDB.objects.filter(external_id=l_intbeh.external_id).first() # pylint: disable=no-member ldb=BehaviorDB.objects.filter(external_id=l_ludbeh.external_id).first() # pylint: disable=no-member #check each behavior persistence assert pf2.interactivity.issubset(idb.to_obj()) and pf2.interactivity.issuperset(idb.to_obj()) assert pf2.ludic.issubset(ldb.to_obj()) and pf2.ludic.issuperset(ldb.to_obj())
def __init__(self, persuasive_=None, aesthetic_=None, orchestration_=None, reification_=None): if persuasive_ and (not isinstance(persuasive_, PersuasiveFunctionAO)): raise TypeError( "ERROR: Parameter is not a valid PersuasiveFunctionAO object") if aesthetic_ and (not isinstance(aesthetic_, AestheticFunctionAO)): raise TypeError( "ERROR: Parameter is not a valid AestheticFunctionAO object") if orchestration_ and (not isinstance(orchestration_, OrchestrationFunctionAO)): raise TypeError( "ERROR: Parameter is not a valid OrchestrationFunctionAO object" ) if reification_ and (not isinstance(reification_, ReificationFunctionAO)): raise TypeError( "ERROR: Parameter is not a valid ReificationFunctionAO object") self.external_id = None self.user = None self.game = None #create empty functions to be able to operate self.persuasive_function = persuasive_ if persuasive_ else PersuasiveFunctionAO( ) self.aesthetic_function = aesthetic_ if aesthetic_ else AestheticFunctionAO( ) self.orchestration_function = orchestration_ if orchestration_ else OrchestrationFunctionAO( ) self.reification_function = reification_ if reification_ else ReificationFunctionAO( ) self.history = [] self.date_creation = None self.date_modified = None self.is_composite = False self.unassigned = []