Exemplo n.º 1
0
 def testRisk_CalculatedEvaluation(self):
     from euphorie.content.risk import Risk
     risk = Risk()
     risk.type = "risk"
     risk.title = u"Can your windows be locked?"
     risk.problem_description = u"Not all your windows can be locked"
     risk.description = u"<p>Locking windows is critical.</p>"
     risk.legal_reference = None
     risk.show_notapplicable = True
     risk.evaluation_method = "calculated"
     risk.default_probability = 1
     risk.default_frequency = 4
     risk.default_effect = 0
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportRisk(root, risk)
     self.assertEqual(etree.tostring(root, pretty_print=True),
             '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
             '  <risk type="risk">\n'
             '    <title>Can your windows be locked?</title>\n'
             '    <problem-description>Not all your windows can be '
             'locked</problem-description>\n'
             '    <description>&lt;p&gt;Locking windows is critical.'
             '&lt;/p&gt;</description>\n'
             '    <show-not-applicable>true</show-not-applicable>\n'
             '    <evaluation-method default-probability="small" '
             'default-frequency="regular">calculated</evaluation-method>\n'
             '  </risk>\n'
             '</root>\n')
Exemplo n.º 2
0
 def testRisk_TwoImages(self):
     from euphorie.content.risk import Risk
     risk = Risk()
     risk.type = "top5"
     risk.title = u"Can your windows be locked?"
     risk.problem_description = u"Not all your windows can be locked"
     risk.description = u"<p>Locking windows is critical.</p>"
     risk.legal_reference = None
     risk.show_notapplicable = False
     risk.image = MockImage("hot stuff here")
     risk.caption = u"Image caption 1"
     risk.image2 = MockImage("hot stuff here")
     risk.caption2 = u"Image caption 2"
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportRisk(root, risk)
     self.assertEqual(etree.tostring(root, pretty_print=True),
             '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
             '  <risk type="top5">\n'
             '    <title>Can your windows be locked?</title>\n'
             '    <problem-description>Not all your windows can be locked'
             '</problem-description>\n'
             '    <description>&lt;p&gt;Locking windows is critical.'
             '&lt;/p&gt;</description>\n'
             '    <show-not-applicable>false</show-not-applicable>\n'
             '    <image caption="Image caption 1">aG90IHN0dWZmIGhlcmU=\n'
             '</image>\n'
             '    <image caption="Image caption 2">aG90IHN0dWZmIGhlcmU=\n'
             '</image>\n'
             '  </risk>\n'
             '</root>\n')
Exemplo n.º 3
0
 def testRisk_TwoImages(self):
     from euphorie.content.risk import Risk
     risk = Risk()
     risk.type = "top5"
     risk.title = u"Can your windows be locked?"
     risk.problem_description = u"Not all your windows can be locked"
     risk.description = u"<p>Locking windows is critical.</p>"
     risk.legal_reference = None
     risk.show_notapplicable = False
     risk.image = MockImage("hot stuff here")
     risk.caption = u"Image caption 1"
     risk.image2 = MockImage("hot stuff here")
     risk.caption2 = u"Image caption 2"
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportRisk(root, risk)
     self.assertEqual(
         etree.tostring(root, pretty_print=True),
         '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
         '  <risk type="top5">\n'
         '    <title>Can your windows be locked?</title>\n'
         '    <problem-description>Not all your windows can be locked'
         '</problem-description>\n'
         '    <description>&lt;p&gt;Locking windows is critical.'
         '&lt;/p&gt;</description>\n'
         '    <show-not-applicable>false</show-not-applicable>\n'
         '    <image caption="Image caption 1">aG90IHN0dWZmIGhlcmU=\n'
         '</image>\n'
         '    <image caption="Image caption 2">aG90IHN0dWZmIGhlcmU=\n'
         '</image>\n'
         '  </risk>\n'
         '</root>\n')
Exemplo n.º 4
0
 def testRisk_CalculatedEvaluation(self):
     from euphorie.content.risk import Risk
     risk = Risk()
     risk.type = "risk"
     risk.title = u"Can your windows be locked?"
     risk.problem_description = u"Not all your windows can be locked"
     risk.description = u"<p>Locking windows is critical.</p>"
     risk.legal_reference = None
     risk.show_notapplicable = True
     risk.evaluation_method = "calculated"
     risk.default_probability = 1
     risk.default_frequency = 4
     risk.default_effect = 0
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportRisk(root, risk)
     self.assertEqual(
         etree.tostring(root, pretty_print=True),
         '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
         '  <risk type="risk">\n'
         '    <title>Can your windows be locked?</title>\n'
         '    <problem-description>Not all your windows can be '
         'locked</problem-description>\n'
         '    <description>&lt;p&gt;Locking windows is critical.'
         '&lt;/p&gt;</description>\n'
         '    <show-not-applicable>true</show-not-applicable>\n'
         '    <evaluation-method default-probability="small" '
         'default-frequency="regular">calculated</evaluation-method>\n'
         '  </risk>\n'
         '</root>\n')
Exemplo n.º 5
0
 def testRisk_Minimal(self):
     from euphorie.content.risk import Risk
     risk = Risk()
     risk.type = "top5"
     risk.title = u"Can your windows be locked?"
     risk.problem_description = u"Not all your windows can be locked"
     risk.description = u"<p>Locking windows is critical.</p>"
     risk.legal_reference = None
     risk.show_notapplicable = False
     root = self.root()
     view = ExportSurvey(None, None)
     node = view.exportRisk(root, risk)
     self.assertTrue(node in root)
     self.assertEqual(
         etree.tostring(root, pretty_print=True),
         '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
         '  <risk type="top5">\n'
         '    <title>Can your windows be locked?</title>\n'
         '    <problem-description>Not all your windows can be locked'
         '</problem-description>\n'
         '    <description>&lt;p&gt;Locking windows is '
         'critical.&lt;/p&gt;</description>\n'
         '    <show-not-applicable>false</show-not-applicable>\n'
         '  </risk>\n'
         '</root>\n')
Exemplo n.º 6
0
 def testRisk_WithSolution(self):
     from euphorie.content.solution import Solution
     from euphorie.content.risk import Risk
     risk = Risk()
     risk.type = "top5"
     risk.title = u"Can your windows be locked?"
     risk.problem_description = u"Not all your windows can be locked"
     risk.description = u"<p>Locking windows is critical.</p>"
     risk.legal_reference = None
     risk.show_notapplicable = False
     solution = Solution()
     solution.description = u"<p>Test description</p>"
     solution.action_plan = u"Sample action plan"
     solution.prevention_plan = None
     solution.requirements = None
     risk["1"] = solution
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportRisk(root, risk)
     self.assertEqual(
         etree.tostring(root, pretty_print=True),
         '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
         '  <risk type="top5">\n'
         '    <title>Can your windows be locked?</title>\n'
         '    <problem-description>Not all your windows can be locked'
         '</problem-description>\n'
         '    <description>&lt;p&gt;Locking windows is critical.'
         '&lt;/p&gt;</description>\n'
         '    <show-not-applicable>false</show-not-applicable>\n'
         '    <solutions>\n'
         '      <solution>\n'
         '        <description>&lt;p&gt;Test description&lt;/p&gt;'
         '</description>\n'
         '        <action-plan>Sample action plan</action-plan>\n'
         '      </solution>\n'
         '    </solutions>\n'
         '  </risk>\n'
         '</root>\n')
Exemplo n.º 7
0
 def testRisk_LegalReferenceNoText(self):
     from euphorie.content.risk import Risk
     risk = Risk()
     risk.type = "top5"
     risk.title = u"Can your windows be locked?"
     risk.problem_description = u"Not all your windows can be locked"
     risk.description = u"<p>Locking windows is critical.</p>"
     risk.legal_reference = u"<p><br/></p>"
     risk.show_notapplicable = False
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportRisk(root, risk)
     self.assertEqual(etree.tostring(root, pretty_print=True),
             '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
             '  <risk type="top5">\n'
             '    <title>Can your windows be locked?</title>\n'
             '    <problem-description>Not all your windows can be locked'
             '</problem-description>\n'
             '    <description>&lt;p&gt;Locking windows is critical.'
             '&lt;/p&gt;</description>\n'
             '    <show-not-applicable>false</show-not-applicable>\n'
             '  </risk>\n'
             '</root>\n')
Exemplo n.º 8
0
 def testRisk_WithSolution(self):
     from euphorie.content.solution import Solution
     from euphorie.content.risk import Risk
     risk = Risk()
     risk.type = "top5"
     risk.title = u"Can your windows be locked?"
     risk.problem_description = u"Not all your windows can be locked"
     risk.description = u"<p>Locking windows is critical.</p>"
     risk.legal_reference = None
     risk.show_notapplicable = False
     solution = Solution()
     solution.description = u"<p>Test description</p>"
     solution.action_plan = u"Sample action plan"
     solution.prevention_plan = None
     solution.requirements = None
     risk["1"] = solution
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportRisk(root, risk)
     self.assertEqual(etree.tostring(root, pretty_print=True),
             '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
             '  <risk type="top5">\n'
             '    <title>Can your windows be locked?</title>\n'
             '    <problem-description>Not all your windows can be locked'
             '</problem-description>\n'
             '    <description>&lt;p&gt;Locking windows is critical.'
             '&lt;/p&gt;</description>\n'
             '    <show-not-applicable>false</show-not-applicable>\n'
             '    <solutions>\n'
             '      <solution>\n'
             '        <description>&lt;p&gt;Test description&lt;/p&gt;'
             '</description>\n'
             '        <action-plan>Sample action plan</action-plan>\n'
             '      </solution>\n'
             '    </solutions>\n'
             '  </risk>\n'
             '</root>\n')