def testRisk_DirectEvaluation(self): risk = Risk() risk.type = "risk" risk.title = "Can your windows be locked?" risk.problem_description = "Not all your windows can be locked" risk.description = "<p>Locking windows is critical.</p>" risk.legal_reference = None risk.show_notapplicable = True risk.evaluation_method = "direct" risk.default_priority = "low" root = self.root() view = ExportSurvey(None, None) view.exportRisk(root, risk) self.assertEqual( safe_nativestring(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><p>Locking windows is " "critical.</p></description>\n" " <show-not-applicable>true</show-not-applicable>\n" ' <evaluation-method default-priority="low">direct' "</evaluation-method>\n" " </risk>\n" "</root>\n", )
def testRisk_DirectEvaluation(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 = "direct" risk.default_priority = "low" 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><p>Locking windows is ' 'critical.</p></description>\n' ' <show-not-applicable>true</show-not-applicable>\n' ' <evaluation-method default-priority="low">direct' '</evaluation-method>\n' ' </risk>\n' '</root>\n')
def testModule_WithRisk(self): module = Module() module.title = "Office buildings" module.description = "<p>Owning property brings risks.</p>" module.optional = False module.solution_direction = None risk = Risk() risk.type = "top5" risk.title = "Can your windows be locked?" risk.problem_description = "Not all your windows can be locked" risk.description = "<p>Locking windows is critical.</p>" risk.legal_reference = None risk.show_notapplicable = False module._setOb("1", risk) root = self.root() view = ExportSurvey(None, None) view.exportModule(root, module) self.assertEqual( safe_nativestring(etree.tostring(root, pretty_print=True)), '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n' ' <module optional="false">\n' " <title>Office buildings</title>\n" " <description><p>Owning property brings risks." "</p></description>\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><p>Locking windows is critical." "</p></description>\n" " <show-not-applicable>false</show-not-applicable>\n" " </risk>\n" " </module>\n" "</root>\n", )
def testRisk_Minimal(self): risk = Risk() risk.type = "top5" risk.title = "Can your windows be locked?" risk.problem_description = "Not all your windows can be locked" risk.description = "<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( safe_nativestring(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><p>Locking windows is " "critical.</p></description>\n" " <show-not-applicable>false</show-not-applicable>\n" " </risk>\n" "</root>\n", )
def testModule_WithRisk(self): from euphorie.content.module import Module from euphorie.content.risk import Risk module = Module() module.title = u"Office buildings" module.description = u"<p>Owning property brings risks.</p>" module.optional = False module.solution_direction = None 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 module["1"] = risk root = self.root() view = ExportSurvey(None, None) view.exportModule(root, module) self.assertEqual(etree.tostring(root, pretty_print=True), '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n' ' <module optional="false">\n' ' <title>Office buildings</title>\n' ' <description><p>Owning property brings risks.' '</p></description>\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><p>Locking windows is critical.' '</p></description>\n' ' <show-not-applicable>false</show-not-applicable>\n' ' </risk>\n' ' </module>\n' '</root>\n')
def testRisk_WithSolution(self): risk = Risk() risk.type = "top5" risk.title = "Can your windows be locked?" risk.problem_description = "Not all your windows can be locked" risk.description = "<p>Locking windows is critical.</p>" risk.legal_reference = None risk.show_notapplicable = False solution = Solution() solution.description = "<p>Test description</p>" solution.action = "Sample action plan" solution.requirements = None risk._setOb("1", solution) root = self.root() view = ExportSurvey(None, None) view.exportRisk(root, risk) self.assertEqual( safe_nativestring(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><p>Locking windows is critical." "</p></description>\n" " <show-not-applicable>false</show-not-applicable>\n" " <solutions>\n" " <solution>\n" " <description><p>Test description</p>" "</description>\n" " <action>Sample action plan</action>\n" " </solution>\n" " </solutions>\n" " </risk>\n" "</root>\n", )
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><p>Locking windows is critical.' '</p></description>\n' ' <show-not-applicable>false</show-not-applicable>\n' ' <solutions>\n' ' <solution>\n' ' <description><p>Test description</p>' '</description>\n' ' <action-plan>Sample action plan</action-plan>\n' ' </solution>\n' ' </solutions>\n' ' </risk>\n' '</root>\n')
def testProfileQuestion_WithRisk(self): from euphorie.content.profilequestion import ProfileQuestion from euphorie.content.risk import Risk profile = ProfileQuestion() profile.title = u"Office buildings" profile.question = u"Do you have an office buildings?" profile.description = u"<p>Owning property brings risks.</p>" 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 profile["1"] = risk root = self.root() view = ExportSurvey(None, None) view.exportProfileQuestion(root, profile) self.assertEqual( etree.tostring(root, pretty_print=True), '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n' ' <profile-question>\n' ' <title>Office buildings</title>\n' ' <question>Do you have an office buildings?</question>\n' ' <description><p>Owning property brings risks.' '</p></description>\n' ' <use-location-question>true</use-location-question>\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><p>Locking windows is critical.' '</p></description>\n' ' <show-not-applicable>false</show-not-applicable>\n' ' </risk>\n' ' </profile-question>\n' '</root>\n')
def testProfileQuestion_WithRisk(self): profile = ProfileQuestion() profile.title = "Office buildings" profile.question = "Do you have an office buildings?" profile.description = "<p>Owning property brings risks.</p>" risk = Risk() risk.type = "top5" risk.title = "Can your windows be locked?" risk.problem_description = "Not all your windows can be locked" risk.description = "<p>Locking windows is critical.</p>" risk.legal_reference = None risk.show_notapplicable = False profile._setOb("1", risk) root = self.root() view = ExportSurvey(None, None) view.exportProfileQuestion(root, profile) self.assertEqual( safe_nativestring(etree.tostring(root, pretty_print=True)), '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n' " <profile-question>\n" " <title>Office buildings</title>\n" " <question>Do you have an office buildings?</question>\n" " <description><p>Owning property brings risks." "</p></description>\n" " <use-location-question>true</use-location-question>\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><p>Locking windows is critical." "</p></description>\n" " <show-not-applicable>false</show-not-applicable>\n" " </risk>\n" " </profile-question>\n" "</root>\n", )
def testModule_WithRisk(self): from euphorie.content.module import Module from euphorie.content.risk import Risk module = Module() module.title = u"Office buildings" module.description = u"<p>Owning property brings risks.</p>" module.optional = False module.solution_direction = None 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 module["1"] = risk root = self.root() view = ExportSurvey(None, None) view.exportModule(root, module) self.assertEqual( etree.tostring(root, pretty_print=True), '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n' ' <module optional="false">\n' ' <title>Office buildings</title>\n' ' <description><p>Owning property brings risks.' '</p></description>\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><p>Locking windows is critical.' '</p></description>\n' ' <show-not-applicable>false</show-not-applicable>\n' ' </risk>\n' ' </module>\n' '</root>\n')
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><p>Locking windows is critical.' '</p></description>\n' ' <show-not-applicable>false</show-not-applicable>\n' ' </risk>\n' '</root>\n')
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><p>Locking windows is critical.' '</p></description>\n' ' <show-not-applicable>false</show-not-applicable>\n' ' </risk>\n' '</root>\n')
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><p>Locking windows is critical.' '</p></description>\n' ' <show-not-applicable>false</show-not-applicable>\n' ' <solutions>\n' ' <solution>\n' ' <description><p>Test description</p>' '</description>\n' ' <action-plan>Sample action plan</action-plan>\n' ' </solution>\n' ' </solutions>\n' ' </risk>\n' '</root>\n')
def testProfileQuestion_WithRisk(self): from euphorie.content.profilequestion import ProfileQuestion from euphorie.content.risk import Risk profile = ProfileQuestion() profile.title = u"Office buildings" profile.question = u"Do you have an office buildings?" profile.description = u"<p>Owning property brings risks.</p>" profile.type = "optional" 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 profile["1"] = risk root = self.root() view = ExportSurvey(None, None) view.exportProfileQuestion(root, profile) self.assertEqual(etree.tostring(root, pretty_print=True), '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n' ' <profile-question>\n' ' <title>Office buildings</title>\n' ' <question>Do you have an office buildings?</question>\n' ' <description><p>Owning property brings risks.' '</p></description>\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><p>Locking windows is critical.' '</p></description>\n' ' <show-not-applicable>false</show-not-applicable>\n' ' </risk>\n' ' </profile-question>\n' '</root>\n')
def test_RiskNotApplicable(self): zodbnode = Risk() zodbnode.problem_description = None node = model.Risk(type="risk", identification="n/a") self.assertEqual(self._call(node, zodbnode), False)
def test_show_Unanswered(self): # https//code.simplon.biz/tracker/tno-euphorie/ticket/75 zodbnode = Risk() zodbnode.problem_description = None node = model.Risk(type="risk") self.assertEqual(self._call(node, zodbnode), False)
def testDefaultEvaluationAlgorithm(self): from euphorie.content.risk import Risk risk = Risk() self.assertEqual(risk.evaluation_algorithm(), u"kinney")
def test_HasEmptyProblemDescription(self): zodbnode = Risk() zodbnode.problem_description = u" " node = model.Risk(type="risk", identification="no") self.assertEqual(self._call(node, zodbnode), True)
def test_Present(self): zodbnode = Risk() zodbnode.problem_description = None node = model.Risk(type="risk", identification="no") self.assertEqual(self._call(node, zodbnode), True)
def testRisk_TwoImages(self): risk = Risk() risk.type = "top5" risk.title = "Can your windows be locked?" risk.problem_description = "Not all your windows can be locked" risk.description = "<p>Locking windows is critical.</p>" risk.legal_reference = None risk.show_notapplicable = False risk.image = MockImage("hot stuff here") risk.caption = "Image caption 1" risk.image2 = MockImage("hot stuff here") risk.caption2 = "Image caption 2" root = self.root() view = ExportSurvey(None, None) view.include_images = True view.exportRisk(root, risk) self.assertEqual( safe_nativestring(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><p>Locking windows is critical." "</p></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", )
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><p>Locking windows is critical.' '</p></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')
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><p>Locking windows is critical.' '</p></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')
def testDefaultEvaluationAlgorithm(self): risk = Risk() self.assertEqual(risk.evaluation_algorithm(), "kinney")