コード例 #1
0
 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>&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",
     )
コード例 #2
0
 def testImage_Minimal(self):
     image = MockImage("hot stuff here")
     root = self.root()
     view = ExportSurvey(None, None)
     view.include_images = True
     node = view.exportImage(root, image)
     self.assertTrue(node in root)
     self.assertEqual(
         safe_nativestring(etree.tostring(node, pretty_print=True)),
         '<image xmlns="http://xml.simplon.biz/euphorie/survey/1.0">'
         "aG90IHN0dWZmIGhlcmU=\n</image>\n",
     )
コード例 #3
0
 def testImage_Full(self):
     image = MockImage("hot stuff here", "test.gif", "image/gif")
     root = self.root()
     view = ExportSurvey(None, None)
     view.include_images = True
     image = view.exportImage(root, image, "Captiøn")
     self.assertEqual(
         safe_nativestring(etree.tostring(image, pretty_print=True)),
         '<image xmlns="http://xml.simplon.biz/euphorie/survey/1.0" '
         'content-type="image/gif" filename="test.gif" '
         'caption="Capti&#xF8;n">aG90IHN0dWZmIGhlcmU=\n'
         "</image>\n",
     )
コード例 #4
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",
     )