Example #1
0
 def testModule_WithSubModule(self):
     module = Module()
     module.title = "Office buildings"
     module.description = "<p>Owning property brings risks.</p>"
     module.optional = False
     module.solution_direction = None
     submodule = Module()
     submodule.title = "Parking"
     submodule.description = "<p>All about parking garages.</p>"
     submodule.optional = False
     submodule.solution_direction = None
     module._setOb("1", submodule)
     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>&lt;p&gt;Owning property brings risks."
         "&lt;/p&gt;</description>\n"
         '    <module optional="false">\n'
         "      <title>Parking</title>\n"
         "      <description>&lt;p&gt;All about parking garages."
         "&lt;/p&gt;</description>\n"
         "    </module>\n"
         "  </module>\n"
         "</root>\n",
     )
Example #2
0
 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>&lt;p&gt;Owning property brings risks."
         "&lt;/p&gt;</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>&lt;p&gt;Locking windows is critical."
         "&lt;/p&gt;</description>\n"
         "      <show-not-applicable>false</show-not-applicable>\n"
         "    </risk>\n"
         "  </module>\n"
         "</root>\n",
     )
Example #3
0
 def testModule_with_description(self):
     module = Module()
     module.title = "Office buildings"
     module.description = "<p>Owning property brings risks.</p>"
     module.solution_direction = None
     module.optional = False
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportModule(root, module)
     xml = safe_nativestring(etree.tostring(root, pretty_print=True))
     self.assertTrue("<description>&lt;p&gt;Owning property brings risks."
                     "&lt;/p&gt;</description>\n" in xml)
Example #4
0
 def testModule_SolutionDirectionNoText(self):
     module = Module()
     module.title = "Office buildings"
     module.description = "<p>Owning property brings risks.</p>"
     module.optional = False
     module.solution_direction = "<p><br/></p>"
     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>&lt;p&gt;Owning property brings risks."
         "&lt;/p&gt;</description>\n"
         "  </module>\n"
         "</root>\n",
     )
Example #5
0
 def testModule_Image(self):
     module = Module()
     module.title = "Office buildings"
     module.description = "<p>Owning property brings risks.</p>"
     module.optional = False
     module.solution_direction = None
     module.image = MockImage("hot stuff here")
     root = self.root()
     view = ExportSurvey(None, None)
     view.include_images = True
     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>&lt;p&gt;Owning property brings risks."
         "&lt;/p&gt;</description>\n"
         "    <image>aG90IHN0dWZmIGhlcmU=\n"
         "</image>\n"
         "  </module>\n"
         "</root>\n",
     )
Example #6
0
 def testModule_Minimal(self):
     module = Module()
     module.title = "Office buildings"
     module.optional = False
     module.solution_direction = None
     root = self.root()
     view = ExportSurvey(None, None)
     node = view.exportModule(root, module)
     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'
         '  <module optional="false">\n'
         "    <title>Office buildings</title>\n"
         "  </module>\n"
         "</root>\n",
     )