def testProfileQuestion_WithModule(self): from euphorie.content.profilequestion import ProfileQuestion from euphorie.content.module import Module 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>" module = Module() module.title = u"Office buildings" module.description = u"<p>Owning property brings risks.</p>" module.optional = False module.solution_direction = None profile["1"] = module 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' ' <module optional="false">\n' ' <title>Office buildings</title>\n' ' <description><p>Owning property brings ' 'risks.</p></description>\n' ' </module>\n' ' </profile-question>\n' '</root>\n')
def testProfileQuestion_WithModule(self): from euphorie.content.profilequestion import ProfileQuestion from euphorie.content.module import Module 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" module = Module() module.title = u"Office buildings" module.description = u"<p>Owning property brings risks.</p>" module.optional = False module.solution_direction = None profile["1"] = module 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' ' <module optional="false">\n' ' <title>Office buildings</title>\n' ' <description><p>Owning property brings ' 'risks.</p></description>\n' ' </module>\n' ' </profile-question>\n' '</root>\n')
def testProfileQuestion_with_description(self): from euphorie.content.profilequestion import ProfileQuestion profile = ProfileQuestion() profile.title = u"Office buildings" profile.description = u"<p>Owning property brings risks.</p>" root = self.root() view = ExportSurvey(None, None) view.exportProfileQuestion(root, profile) xml = etree.tostring(root, pretty_print=True) self.assertTrue('<description><p>Owning property brings risks.' '</p></description>' in xml)
def testProfileQuestion_with_description(self): from euphorie.content.profilequestion import ProfileQuestion profile = ProfileQuestion() profile.title = u"Office buildings" profile.description = u"<p>Owning property brings risks.</p>" profile.type = 'optional' root = self.root() view = ExportSurvey(None, None) view.exportProfileQuestion(root, profile) xml = etree.tostring(root, pretty_print=True) self.assertTrue( '<description><p>Owning property brings risks.' '</p></description>' in xml)
def testProfileQuestion_LocationQuestions(self): from euphorie.content.profilequestion import ProfileQuestion profile = ProfileQuestion() profile.title = u"Office buildings" profile.question = u"Do you have an office building?" profile.label_multiple_present = u"Do you have more than one building?" profile.label_single_occurance = u"Enter the name of your building." profile.label_multiple_occurances = u"Enter the names of each of your buildings." root = self.root() view = ExportSurvey(None, None) node = view.exportProfileQuestion(root, profile) self.assertTrue(node in root) 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 building?</question>\n' ' <label-multiple-present>Do you have more than one building' '?</label-multiple-present>\n' ' <label-single-occurance>Enter the name of your building.' '</label-single-occurance>\n' ' <label-multiple-occurances>Enter the names of each of your' ' buildings.</label-multiple-occurances>\n' ' <use-location-question>true</use-location-question>\n' ' </profile-question>\n' '</root>\n')
def testProfileQuestion_WithoutQuestion(self): from euphorie.content.profilequestion import ProfileQuestion profile = ProfileQuestion() profile.title = u"Office buildings" profile.description = u"<p>Owning property brings risks.</p>" profile.type = "optional" 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>Office buildings</question>\n' ' <description><p>Owning property brings risks.' '</p></description>\n' ' </profile-question>\n' '</root>\n')
def testProfileQuestion_WithoutQuestion(self): from euphorie.content.profilequestion import ProfileQuestion profile = ProfileQuestion() profile.title = u"Office buildings" profile.description = u"<p>Owning property brings risks.</p>" profile.use_location_question = False 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>Office buildings</question>\n' ' <description><p>Owning property brings risks.' '</p></description>\n' ' <use-location-question>false</use-location-question>\n' ' </profile-question>\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): 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 testProfileQuestion_Minimal(self): from euphorie.content.profilequestion import ProfileQuestion profile = ProfileQuestion() profile.title = u"Office buildings" profile.question = u"Do you have an office building?" profile.type = "optional" root = self.root() view = ExportSurvey(None, None) node = view.exportProfileQuestion(root, profile) self.assertTrue(node in root) 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 building?</question>\n' ' </profile-question>\n' '</root>\n')
def testProfileQuestion_Minimal(self): from euphorie.content.profilequestion import ProfileQuestion profile = ProfileQuestion() profile.title = u"Office buildings" profile.question = u"Do you have an office building?" profile.use_location_question = False root = self.root() view = ExportSurvey(None, None) node = view.exportProfileQuestion(root, profile) self.assertTrue(node in root) 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 building?</question>\n' ' <use-location-question>false</use-location-question>\n' ' </profile-question>\n' '</root>\n')