def test_risk_with_interfaces_already_set(self): from euphorie.content.tests.utils import createSector from euphorie.content.tests.utils import addSurvey from euphorie.content.risk import IKinneyEvaluation from euphorie.content.risk import IFrenchEvaluation self.loginAsPortalOwner() sector = createSector(self.portal) survey = addSurvey(sector) risk = survey["1"]["2"] self.assertTrue(IKinneyEvaluation.providedBy(risk)) self.assertTrue(not IFrenchEvaluation.providedBy(risk)) self.set_evaluation_method_interfaces(self.portal) self.assertTrue(IKinneyEvaluation.providedBy(risk)) self.assertTrue(not IFrenchEvaluation.providedBy(risk))
def test_set_kinney_interface(self): from zope.interface import noLongerProvides from euphorie.content.tests.utils import createSector from euphorie.content.tests.utils import addSurvey from euphorie.content.risk import IKinneyEvaluation from euphorie.content.risk import IFrenchEvaluation self.loginAsPortalOwner() sector = createSector(self.portal) survey = addSurvey(sector) risk = survey["1"]["2"] noLongerProvides(risk, IKinneyEvaluation) self.assertTrue(not IKinneyEvaluation.providedBy(risk)) self.set_evaluation_method_interfaces(self.portal) self.assertTrue(IKinneyEvaluation.providedBy(risk)) self.assertTrue(not IFrenchEvaluation.providedBy(risk))
def testImportRisk_CalculatedEvaluation_French(self): from Acquisition import aq_parent from euphorie.content.risk import IFrenchEvaluation snippet = objectify.fromstring( """<risk type="risk" xmlns="http://xml.simplon.biz/euphorie/survey/1.0"> <title>Are your desks at the right height?</title> <description><p>The right height is important to prevent back problems.</p></description> <evaluation-method default-severity="very-severe" default-frequency="often">calculated</evaluation-method> </risk>""") self.loginAsPortalOwner() module = self.createModule() group = aq_parent(aq_parent(module)) group.evaluation_algorithm = u"french" importer = upload.SurveyImporter(None) risk = importer.ImportRisk(snippet, module) self.assertTrue(IFrenchEvaluation.providedBy(risk)) self.assertEqual(risk.show_notapplicable, False) self.assertEqual(risk.evaluation_method, "calculated") self.assertEqual(risk.default_severity, 10) self.assertEqual(risk.default_frequency, 7)