Exemplo n.º 1
0
 def testSolution_Minimal(self):
     from euphorie.content.solution import Solution
     solution = Solution()
     solution.description = u"<p>Test description</p>"
     solution.action_plan = u"Sample action plan"
     solution.prevention_plan = None
     solution.requirements = None
     root = self.root()
     view = ExportSurvey(None, None)
     node = view.exportSolution(root, solution)
     self.assertTrue(node in root)
     self.assertEqual(etree.tostring(node, pretty_print=True),
             '<solution xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
             '  <description>&lt;p&gt;Test description&lt;/p&gt;'
             '</description>\n'
             '  <action-plan>Sample action plan</action-plan>\n'
             '</solution>\n')
Exemplo n.º 2
0
 def testSolution_Complete(self):
     solution = Solution()
     solution.description = "<p>Tést description</p>"
     solution.action = "Sample actiøn plan"
     solution.requirements = "Requîrements"
     root = self.root()
     view = ExportSurvey(None, None)
     node = view.exportSolution(root, solution)
     self.assertEqual(
         safe_nativestring(etree.tostring(node, pretty_print=True)),
         '<solution xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
         "  <description>&lt;p&gt;T&#233;st description&lt;/p&gt;"
         "</description>\n"
         "  <action>Sample acti&#248;n plan</action>\n"
         "  <requirements>Requ&#238;rements</requirements>\n"
         "</solution>\n",
     )
Exemplo n.º 3
0
 def testSolution_Minimal(self):
     solution = Solution()
     solution.description = "<p>Test description</p>"
     solution.action = "Sample action plan"
     solution.requirements = None
     root = self.root()
     view = ExportSurvey(None, None)
     node = view.exportSolution(root, solution)
     self.assertTrue(node in root)
     self.assertEqual(
         safe_nativestring(etree.tostring(node, pretty_print=True)),
         '<solution xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
         "  <description>&lt;p&gt;Test description&lt;/p&gt;"
         "</description>\n"
         "  <action>Sample action plan</action>\n"
         "</solution>\n",
     )
Exemplo n.º 4
0
 def testSolution_Complete(self):
     from euphorie.content.solution import Solution
     solution = Solution()
     solution.description = u"<p>Tést description</p>"
     solution.action_plan = u"Sample actiøn plan"
     solution.prevention_plan = u"Sample prevention plån"
     solution.requirements = u"Requîrements"
     root = self.root()
     view = ExportSurvey(None, None)
     node = view.exportSolution(root, solution)
     self.assertEqual(etree.tostring(node, pretty_print=True),
             '<solution xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
             '  <description>&lt;p&gt;T&#233;st description&lt;/p&gt;'
             '</description>\n'
             '  <action-plan>Sample acti&#248;n plan</action-plan>\n'
             '  <prevention-plan>Sample prevention pl&#229;n'
             '</prevention-plan>\n'
             '  <requirements>Requ&#238;rements</requirements>\n'
             '</solution>\n')
Exemplo n.º 5
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.º 6
0
 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>&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>Sample action plan</action>\n"
         "      </solution>\n"
         "    </solutions>\n"
         "  </risk>\n"
         "</root>\n",
     )
Exemplo n.º 7
0
 def test_do_GET_full(self):
     from sqlalchemy.orm import object_session
     from zope.publisher.browser import TestRequest
     from euphorie.client.model import Risk
     from euphorie.content.solution import Solution
     from plone.namedfile.file import NamedBlobImage
     self.loginAsPortalOwner()
     (account, survey, survey_session) = _setup_session(self.portal)
     risk = survey['1']['2']
     risk.description = u'<p>Simple description</p>'
     risk.legal_reference = u'<p>Catch 22</p>'
     risk.evaluation_method = 'calculated'
     risk.image2 = NamedBlobImage(data=DUMMY_GIF,
                                  contentType='image/gif',
                                  filename=u'dummy.gif')
     risk.caption2 = u'Secondary Image'
     risk['3'] = Solution(description=u'Standard solution 1',
                          action_plan=u'Dummy plan',
                          requirements=u'Dummy requirements')
     request = TestRequest()
     request.survey = survey
     risk = object_session(survey_session).query(Risk).first()
     risk.skip_children = True
     view = self.View(risk, request)
     response = view.do_GET()
     self.assertEqual(
         set(response),
         set([
             'id', 'type', 'title', 'module-title', 'problem-description',
             'show-not-applicable', 'evaluation-method', 'present',
             'priority', 'comment', 'description', 'legal-reference',
             'evaluation-algorithm', 'frequency', 'frequency-options',
             'effect', 'effect-options', 'probability',
             'probability-options', 'images', 'standard-solutions'
         ]))
     self.assertEqual(response['description'], u'<p>Simple description</p>')
     self.assertEqual(response['legal-reference'], u'<p>Catch 22</p>')
     self.assertEqual(len(response['images']), 2)
     self.assertEqual(len(response['standard-solutions']), 1)
     self.assertEqual(
         response['standard-solutions'][0], {
             'description': u'Standard solution 1',
             'action-plan': u'Dummy plan',
             'prevention-plan': None,
             'requirements': u'Dummy requirements'
         })
Exemplo n.º 8
0
 def testSolution_Minimal(self):
     from euphorie.content.solution import Solution
     solution = Solution()
     solution.description = u"<p>Test description</p>"
     solution.action_plan = u"Sample action plan"
     solution.prevention_plan = None
     solution.requirements = None
     root = self.root()
     view = ExportSurvey(None, None)
     node = view.exportSolution(root, solution)
     self.assertTrue(node in root)
     self.assertEqual(
         etree.tostring(node, pretty_print=True),
         '<solution xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
         '  <description>&lt;p&gt;Test description&lt;/p&gt;'
         '</description>\n'
         '  <action-plan>Sample action plan</action-plan>\n'
         '</solution>\n')
Exemplo n.º 9
0
 def testSolution_Complete(self):
     from euphorie.content.solution import Solution
     solution = Solution()
     solution.description = u"<p>Tést description</p>"
     solution.action_plan = u"Sample actiøn plan"
     solution.prevention_plan = u"Sample prevention plån"
     solution.requirements = u"Requîrements"
     root = self.root()
     view = ExportSurvey(None, None)
     node = view.exportSolution(root, solution)
     self.assertEqual(
         etree.tostring(node, pretty_print=True),
         '<solution xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
         '  <description>&lt;p&gt;T&#233;st description&lt;/p&gt;'
         '</description>\n'
         '  <action-plan>Sample acti&#248;n plan</action-plan>\n'
         '  <prevention-plan>Sample prevention pl&#229;n'
         '</prevention-plan>\n'
         '  <requirements>Requ&#238;rements</requirements>\n'
         '</solution>\n')
Exemplo n.º 10
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')