コード例 #1
0
    def testThatDependentsAreListedAfterDependencies(self):
        attrA = self.addAttributeToCharacter()
        attrB = self.addAttributeToCharacter([attrA])
        attrC = self.addAttributeToCharacter([attrB])
        expected = [attrB, attrC]

        graph = AttributeDependentGraph(attrA)
        actual = list(graph.items())
        self.assertEqual(actual, expected)
コード例 #2
0
    def testThatDependentsOfManyAttributesAreListedAtTheirLatestPosition(self):
        attrA = self.addAttributeToCharacter()
        attrB = self.addAttributeToCharacter([attrA])
        attrC = self.addAttributeToCharacter([attrA, attrB])
        attrD = self.addAttributeToCharacter([attrC])
        expected = [attrB, attrC, attrD]

        graph = AttributeDependentGraph(attrA)
        actual = list(graph.items())
        self.assertEqual(actual, expected)
コード例 #3
0
ファイル: characterAttribute.py プロジェクト: tctimmeh/teledu
  def setValue(self, instance, newValue):
    super(CharacterAttribute, self).setValue(instance, newValue)

    attrGraph = AttributeDependentGraph(self)
    changedAttributes = {self.id: self.getValue(instance)}

    for dependentAttribute in attrGraph.items():
      newValue = dependentAttribute.calculateNewValue(instance)
      changedAttributes[dependentAttribute.id] = newValue

    return changedAttributes
コード例 #4
0
    def testThatDependentsOfAllAttributesAreListed(self):
        pathAFirst = self.addAttributeToCharacter()
        pathASecond = self.addAttributeToCharacter([pathAFirst])
        pathAThird = self.addAttributeToCharacter([pathASecond])
        pathBFirst = self.addAttributeToCharacter()
        pathBSecond = self.addAttributeToCharacter([pathBFirst])
        pathBThird = self.addAttributeToCharacter([pathBSecond])
        bottomAttr = self.addAttributeToCharacter([pathASecond, pathBThird])
        expected = [[pathASecond, pathBSecond], [pathAThird, pathBThird], [bottomAttr]]

        graph = AttributeDependentGraph([pathAFirst, pathBFirst])
        actual = list(graph.items())

        self.assertGraphEqual(actual, expected)