Beispiel #1
0
 def test_TwoPenaltiesHasTwoPenaltyElements(self):
     self.mitigation.addPenalty(
         Penalty("asdf", 1, "asdf", Remediation("myId", "do this"), "asdf"))
     self.mitigation.addPenalty(
         Penalty("asdf", 1, "asdf", Remediation("myId", "do this"), "asdf"))
     self.assertEqual(
         len(self.mitigation.toElement().findall("./*/penalty")), 2)
Beispiel #2
0
 def setUp(self):
     self.penaltyName = "name"
     self.value = 1
     self.reasons = "I have my reasons"
     self.penaltyId = "penaltyId"
     self.remediationText = "This is how you do better"
     self.remediation = Remediation(self.penaltyId, self.remediationText)
     
     
     self.penalty = Penalty(self.penaltyName, self.value, self.reasons, self.remediation, self.penaltyId)
Beispiel #3
0
class Test_PenaltyToElement(unittest.TestCase):
    def setUp(self):
        self.penaltyName = "name"
        self.value = 1
        self.reasons = "I have my reasons"
        self.penaltyId = "penaltyId"
        self.remediationText = "This is how you do better"
        self.remediation = Remediation(self.penaltyId, self.remediationText)
        
        
        self.penalty = Penalty(self.penaltyName, self.value, self.reasons, self.remediation, self.penaltyId)
    
    def tearDown(self):
        pass
    
    
    def test_PenaltyCreatesPenaltyTag(self):
        xml = self.penalty.toElement()
        
        
        self.assertEqual(xml.tag, "penalty")
        
    def test_PenaltyCreatesCorrectAttributesWithTag(self):
        element = self.penalty.toElement()
        
        
        self.assertEqual(element.attrib["name"], self.penaltyName)
        self.assertEqual(element.attrib["value"], str(self.value))
        self.assertEqual(element.attrib["id"], self.penaltyId)
        
        
    def test_PenaltyCreatesReasonChildElement(self):
        element = self.penalty.toElement()
        reasonChild = element.find("reason")
        
        self.assertIsNotNone(reasonChild)
        
        self.assertEqual(reasonChild.tag, "reason")
        self.assertEqual(reasonChild.text, self.reasons)
        
    def test_PenaltyCreatesRemediationChildElement(self):
        element = self.penalty.toElement()
        remediationChild = element.find("remediation")
        
        self.assertIsNotNone(remediationChild)
        
        self.assertEqual(remediationChild.tag, "remediation")
        self.assertEqual(remediationChild.text, self.remediation.getText())
        
        
    def test_PenaltyToElementAsAChild(self):
        parent = ET.Element("top")
        self.penalty.toElement(parent=parent)
        
        self.assertIsNotNone(parent.find("penalty"))
Beispiel #4
0
class Test_RemediationToSubElement(unittest.TestCase):
    def setUp(self):
        self.penaltyName = "name"
        self.value = 1
        self.reasons = "I have my reasons"
        self.penaltyId = "penaltyId"
        self.remediationText = "This is how you do better"
        self.remediation = Remediation(self.penaltyId, self.remediationText)

        self.penalty = Penalty(self.penaltyName, self.value, self.reasons,
                               self.remediation, self.penaltyId)

    def tearDown(self):
        pass

    def test_RemediationAsChildElementHasAParent(self):
        element = ET.Element("top")
        self.remediation.toElement(element)

        self.assertIsNotNone(element.find("remediation"))
Beispiel #5
0
 def test_RemediationCreatesElementText(self):
     remediation = Remediation(self.remediationId, self.remediationText)
     remediationElement = remediation.toElement()
     
     self.assertIsNotNone(remediationElement)
     self.assertEqual(remediationElement.text, self.remediationText)
Beispiel #6
0
 def test_RemediationCreatesIdAttribute(self):
     remediation = Remediation(self.remediationId, self.remediationText)
     remediationElement = remediation.toElement()
     
     self.assertIsNotNone(remediationElement)
     self.assertEqual(remediationElement.attrib["id"], self.remediationId)