Exemple #1
0
 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>&lt;p&gt;Owning property brings '
         'risks.&lt;/p&gt;</description>\n'
         '    <use-location-question>true</use-location-question>\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'
         '  </profile-question>\n'
         '</root>\n')
Exemple #2
0
 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>&lt;p&gt;Owning property brings '
             'risks.&lt;/p&gt;</description>\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'
             '  </profile-question>\n'
             '</root>\n')
Exemple #3
0
 def testProfileQuestion_with_description(self):
     profile = ProfileQuestion()
     profile.title = "Office buildings"
     profile.description = "<p>Owning property brings risks.</p>"
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportProfileQuestion(root, profile)
     xml = safe_nativestring(etree.tostring(root, pretty_print=True))
     self.assertTrue("<description>&lt;p&gt;Owning property brings risks."
                     "&lt;/p&gt;</description>" in xml)
Exemple #4
0
 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>&lt;p&gt;Owning property brings risks.'
                     '&lt;/p&gt;</description>' in xml)
Exemple #5
0
 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>&lt;p&gt;Owning property brings risks.'
             '&lt;/p&gt;</description>' in xml)
Exemple #6
0
 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')
Exemple #7
0
 def testProfileQuestion_LocationQuestions(self):
     profile = ProfileQuestion()
     profile.title = "Office buildings"
     profile.question = "Do you have an office building?"
     profile.label_multiple_present = "Do you have more than one building?"
     profile.label_single_occurance = "Enter the name of your building."
     profile.label_multiple_occurances = (
         "Enter the names of each of your buildings."  # noqa
     )
     root = self.root()
     view = ExportSurvey(None, None)
     node = view.exportProfileQuestion(root, profile)
     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'
         "  <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",
     )
Exemple #8
0
 def testProfileQuestion_WithModule(self):
     profile = ProfileQuestion()
     profile.title = "Office buildings"
     profile.question = "Do you have an office buildings?"
     profile.description = "<p>Owning property brings risks.</p>"
     module = Module()
     module.title = "Office buildings"
     module.description = "<p>Owning property brings risks.</p>"
     module.optional = False
     module.solution_direction = None
     profile._setOb("1", module)
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportProfileQuestion(root, profile)
     self.assertEqual(
         safe_nativestring(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>&lt;p&gt;Owning property brings "
         "risks.&lt;/p&gt;</description>\n"
         "    <use-location-question>true</use-location-question>\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"
         "  </profile-question>\n"
         "</root>\n",
     )
Exemple #9
0
 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')
Exemple #10
0
 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>&lt;p&gt;Owning property brings risks.'
             '&lt;/p&gt;</description>\n'
             '  </profile-question>\n'
             '</root>\n')
Exemple #11
0
 def testProfileQuestion_Minimal(self):
     profile = ProfileQuestion()
     profile.title = "Office buildings"
     profile.question = "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(
         safe_nativestring(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",
     )
Exemple #12
0
 def testProfileQuestion_WithoutQuestion(self):
     profile = ProfileQuestion()
     profile.title = "Office buildings"
     profile.description = "<p>Owning property brings risks.</p>"
     profile.use_location_question = False
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportProfileQuestion(root, profile)
     self.assertEqual(
         safe_nativestring(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>&lt;p&gt;Owning property brings risks."
         "&lt;/p&gt;</description>\n"
         "    <use-location-question>false</use-location-question>\n"
         "  </profile-question>\n"
         "</root>\n",
     )
Exemple #13
0
 def testEtranslateRenderWithoutHTML(self):
     profile = ProfileQuestion()
     profile.title = "Office buildings"
     profile.question = "Do you have an office building?"
     profile.description = "Plain text"
     root = self.root()
     view = ExportSurvey(None, None)
     view.is_etranslate_compatible = True
     node = view.exportProfileQuestion(root, profile)
     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'
         "  <profile-question>\n"
         "    <title>Office buildings</title>\n"
         "    <question>Do you have an office building?</question>\n"
         "    <description>Plain text</description>\n"
         "    <use-location-question>true</use-location-question>\n"
         "  </profile-question>\n"
         "</root>\n",
     )
Exemple #14
0
 def testSurvey_WithProfileQuestion(self):
     from euphorie.content.surveygroup import SurveyGroup
     from euphorie.content.survey import Survey
     from euphorie.content.profilequestion import ProfileQuestion
     surveygroup = SurveyGroup()
     surveygroup.title = u"Generic sector"
     surveygroup["standard"] = Survey()
     survey = surveygroup["standard"]  # Acquisition wrap
     survey.title = u"Generic sector"
     survey.introduction = None
     survey.classification_code = None
     survey.evaluation_optional = False
     survey.language = "en-GB"
     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"
     survey["1"] = profile
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportSurvey(root, survey)
     self.assertEqual(etree.tostring(root, pretty_print=True),
             '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
             '  <survey>\n'
             '    <title>Generic sector</title>\n'
             '    <language>en-GB</language>\n'
             '    <evaluation-algorithm>kinney</evaluation-algorithm>\n'
             '    <evaluation-optional>false</evaluation-optional>\n'
             '    <profile-question>\n'
             '      <title>Office buildings</title>\n'
             '      <question>Do you have an office buildings?</question>\n'
             '      <description>&lt;p&gt;Owning property brings '
             'risks.&lt;/p&gt;</description>\n'
             '    </profile-question>\n'
             '  </survey>\n'
             '</root>\n')
Exemple #15
0
 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>&lt;p&gt;Owning property brings risks.'
         '&lt;/p&gt;</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>&lt;p&gt;Locking windows is critical.'
         '&lt;/p&gt;</description>\n'
         '      <show-not-applicable>false</show-not-applicable>\n'
         '    </risk>\n'
         '  </profile-question>\n'
         '</root>\n')
Exemple #16
0
 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>&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'
             '  </profile-question>\n'
             '</root>\n')
Exemple #17
0
 def test_put_not_all_questions_answered(self):
     import mock
     from euphorie.content.survey import Survey
     from euphorie.content.profilequestion import ProfileQuestion
     from euphorie.client.tests.utils import addAccount
     from euphorie.client.model import SurveySession
     account = addAccount(password='******')
     survey_session = SurveySession(title=u'Dummy session',
                                    zodb_path='nl/ict/software-development',
                                    account=account)
     view = self.View(survey_session, None)
     view.input = {}
     self.portal.survey = Survey(id='survey')
     survey = self.portal.survey
     survey['5'] = ProfileQuestion(id='5', question=u'Locations')
     view.survey = mock.Mock(return_value=survey)
     response = view.do_PUT()
     self.assertEqual(response['type'], 'error')
Exemple #18
0
 def test_get_with_profile(self):
     import mock
     from euphorie.content.survey import Survey
     from euphorie.content.profilequestion import ProfileQuestion
     self.portal.survey = Survey(id='survey')
     survey = self.portal.survey
     survey['5'] = ProfileQuestion(id='5', question=u'Locations')
     view = self.View(survey, None)
     view.survey = mock.Mock(return_value=survey)
     with mock.patch('euphorie.client.api.profile.extractProfile') \
             as mock_extractProfile:
         mock_extractProfile.return_value = {'5': [u'London', u'Tokyo']}
         response = view.do_GET()
         profile = response['profile']
         self.assertEqual(profile, [{
             'id': '5',
             'question': u'Locations',
             'value': [u'London', u'Tokyo']
         }])
Exemple #19
0
 def testProfileQuestion_WithRisk(self):
     profile = ProfileQuestion()
     profile.title = "Office buildings"
     profile.question = "Do you have an office buildings?"
     profile.description = "<p>Owning property brings risks.</p>"
     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
     profile._setOb("1", risk)
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportProfileQuestion(root, profile)
     self.assertEqual(
         safe_nativestring(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>&lt;p&gt;Owning property brings risks."
         "&lt;/p&gt;</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>&lt;p&gt;Locking windows is critical."
         "&lt;/p&gt;</description>\n"
         "      <show-not-applicable>false</show-not-applicable>\n"
         "    </risk>\n"
         "  </profile-question>\n"
         "</root>\n",
     )
Exemple #20
0
 def testSurvey_WithProfileQuestion(self):
     surveygroup = SurveyGroup()
     surveygroup.title = "Generic sector"
     surveygroup._setOb("standard", Survey())
     survey = surveygroup["standard"]  # Acquisition wrap
     survey.title = "Generic sector"
     survey.introduction = None
     survey.classification_code = None
     survey.evaluation_optional = False
     survey.language = "en-GB"
     profile = ProfileQuestion()
     profile.title = "Office buildings"
     profile.question = "Do you have an office buildings?"
     profile.description = "<p>Owning property brings risks.</p>"
     profile.type = "optional"
     survey._setOb("1", profile)
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportSurvey(root, survey)
     self.assertEqual(
         safe_nativestring(etree.tostring(root, pretty_print=True)),
         '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
         "  <survey>\n"
         "    <title>Generic sector</title>\n"
         "    <language>en-GB</language>\n"
         "    <tool_type>classic</tool_type>\n"
         "    <measures_text_handling>full</measures_text_handling>\n"
         "    <integrated_action_plan>false</integrated_action_plan>\n"
         "    <evaluation-algorithm>kinney</evaluation-algorithm>\n"
         "    <evaluation-optional>false</evaluation-optional>\n"
         "    <profile-question>\n"
         "      <title>Office buildings</title>\n"
         "      <question>Do you have an office buildings?</question>\n"
         "      <description>&lt;p&gt;Owning property brings "
         "risks.&lt;/p&gt;</description>\n"
         "      <use-location-question>true</use-location-question>\n"
         "    </profile-question>\n"
         "  </survey>\n"
         "</root>\n",
     )
Exemple #21
0
 def testSurvey_WithProfileQuestion(self):
     from euphorie.content.surveygroup import SurveyGroup
     from euphorie.content.survey import Survey
     from euphorie.content.profilequestion import ProfileQuestion
     surveygroup = SurveyGroup()
     surveygroup.title = u"Generic sector"
     surveygroup["standard"] = Survey()
     survey = surveygroup["standard"]  # Acquisition wrap
     survey.title = u"Generic sector"
     survey.introduction = None
     survey.classification_code = None
     survey.evaluation_optional = False
     survey.language = "en-GB"
     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"
     survey["1"] = profile
     root = self.root()
     view = ExportSurvey(None, None)
     view.exportSurvey(root, survey)
     self.assertEqual(
         etree.tostring(root, pretty_print=True),
         '<root xmlns="http://xml.simplon.biz/euphorie/survey/1.0">\n'
         '  <survey>\n'
         '    <title>Generic sector</title>\n'
         '    <language>en-GB</language>\n'
         '    <evaluation-algorithm>kinney</evaluation-algorithm>\n'
         '    <evaluation-optional>false</evaluation-optional>\n'
         '    <profile-question>\n'
         '      <title>Office buildings</title>\n'
         '      <question>Do you have an office buildings?</question>\n'
         '      <description>&lt;p&gt;Owning property brings '
         'risks.&lt;/p&gt;</description>\n'
         '      <use-location-question>true</use-location-question>\n'
         '    </profile-question>\n'
         '  </survey>\n'
         '</root>\n')