def testInvalidDateDoesNotBreakRendering(self):
     import datetime
     from euphorie.content.tests.utils import BASIC_SURVEY
     from z3c.saconfig import Session
     from euphorie.client import model
     # Test for http://code.simplon.biz/tracker/tno-euphorie/ticket/150
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     browser = Browser()
     survey_url = self.portal.client.nl["ict"]["software-development"]\
             .absolute_url()
     browser.open(survey_url)
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="title:utf8:ustring").value = \
             u"Sessiøn".encode("utf-8")
     browser.getControl(name="next").click()
     # Start the survey
     browser.getForm().submit()
     browser.getLink("Start Risk Identification").click()
     # Update the risk
     risk = Session.query(model.Risk).first()
     risk.identification = "no"
     risk.action_plans.append(model.ActionPlan(
         action_plan=u"Do something awesome",
         planning_start=datetime.date(1, 2, 3)))
     # Render the report
     browser.handleErrors = False
     browser.open("http://nohost/plone/client/nl/ict/"
                     "software-development/report/view")
Example #2
0
 def testShowFrenchEvaluation(self):
     from euphorie.content.tests.utils import BASIC_SURVEY
     # Test for http://code.simplon.biz/tracker/tno-euphorie/ticket/150
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     browser = Browser()
     survey = self.portal.client.nl["ict"]["software-development"]
     survey.evaluation_algorithm = u"french"
     survey["1"]["2"].type = "risk"
     browser.open(survey.absolute_url())
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="title:utf8:ustring").value = \
             u"Sessiøn".encode("utf-8")
     browser.getControl(name="next").click()
     # Start the survey
     browser.getForm().submit()
     browser.getLink("Start Risk Identification").click()
     # Identify the risk
     browser.getControl("next").click()
     browser.getControl(name="answer").value = ["no"]
     # Verify number of options
     self.assertEqual(
             len(browser.getControl(name="frequency:int").controls), 4)
     self.assertEqual(
             len(browser.getControl(name="severity:int").controls), 4)
     # Enter some digits
     browser.getControl(name="frequency:int").value = ["7"]
     browser.getControl(name="severity:int").value = ["10"]
     browser.getControl("next").click()
     # Verify the result
     browser.open(
             "http://nohost/plone/client/nl/ict/"
             "software-development/actionplan/1/1")
     self.assertEqual(browser.getControl(name="priority").value, ["high"])
Example #3
0
 def createClientBrowser(self):
     from Products.Five.testbrowser import Browser
     from euphorie.client.tests.utils import registerUserInClient
     browser = Browser()
     browser.open(self.portal.client.nl["ict"]["software-development"].absolute_url())
     registerUserInClient(browser)
     return browser
 def testShowFrenchEvaluation(self):
     # Test for http://code.simplon.biz/tracker/tno-euphorie/ticket/150
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     survey = self.portal.client.nl["ict"]["software-development"]
     survey.evaluation_algorithm = "french"
     survey["1"]["2"].type = "risk"
     browser = self.get_browser()
     browser.open(survey.absolute_url())
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="survey").value = ["ict/software-development"]
     browser.getForm(action="new-session").submit()
     browser.getControl(name="form.widgets.title").value = "Sessiøn".encode(
         "utf-8")  # noqa
     # Start the survey
     browser.getControl(name="form.button.submit").click()
     session_url = browser.url.replace("/@@identification", "")
     # Identify the risk
     browser.open("%s/1/1/@@identification" % session_url)
     browser.getControl(name="answer").value = ["no"]
     # Verify number of options
     self.assertEqual(
         len(tuple(browser.getControl(name="frequency:int").controls)), 4)
     self.assertEqual(
         len(tuple(browser.getControl(name="severity:int").controls)), 4)
     # Enter some digits
     browser.getControl(name="frequency:int").value = ["7"]
     browser.getControl(name="severity:int").value = ["10"]
     browser.getControl("next").click()
     # Verify the result
     browser.open("%s/1/1/@@actionplan" % session_url)
     self.assertEqual(browser.getControl(name="priority").value, ["high"])
 def testUnicodeReportFilename(self):
     from euphorie.content.tests.utils import BASIC_SURVEY
     # Test for http://code.simplon.biz/tracker/euphorie/ticket/156
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     browser = Browser()
     survey_url = self.portal.client.nl["ict"]["software-development"]\
             .absolute_url()
     browser.open(survey_url)
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="title:utf8:ustring").value = \
             u"Sessiøn".encode("utf-8")
     browser.getControl(name="next").click()
     # Start the survey
     browser.getForm().submit()
     browser.getLink("Start Risk Identification").click()
     # Force creation of the company data
     browser.open("%s/report/company" % survey_url)
     # Download the report
     browser.handleErrors = False
     browser.open("%s/report/download" % survey_url)
     self.assertEqual(browser.headers.type, "application/rtf")
     self.assertEqual(browser.headers.get("Content-Disposition"),
             'attachment; filename="Action plan Sessi\xc3\xb8n.rtf"')
 def test_set_unknown_answer_if_skipped(self):
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     # Register in the client
     browser = self.get_browser()
     survey_url = self.portal.client.nl["ict"][
         "software-development"].absolute_url()  # noqa: E501
     browser.open(survey_url)
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="survey").value = ["ict/software-development"]
     browser.getForm(action="new-session").submit()
     browser.getControl(name="form.widgets.title").value = "Sessiøn".encode(
         "utf-8")  # noqa
     # Start the survey
     browser.getControl(name="form.button.submit").click()
     session_url = browser.url.replace("/@@identification", "")
     # Identify the risk
     browser.open("%s/1/1/@@identification" % session_url)
     # No answer should be set on initial view
     self.assertEqual(browser.getControl(name="answer").value, [])
     # Do not give an identification answer
     risk_url = browser.url
     browser.getControl("next").click()
     # Go back and check the new answer
     browser.open(risk_url)
     self.assertTrue('class="current postponed' in browser.contents)
 def test_surveys_filtered_by_language(self):
     from euphorie.client.tests.utils import registerUserInClient
     survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                   <title>Sector</title>
                   <survey>
                     <title>Survey</title>
                     <language>en</language>
                   </survey>
                 </sector>"""
     survey_nl = \
             """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                 <title>Branche</title>
                 <survey>
                   <title>Vragenlijst</title>
                   <language>nl</language>
                 </survey>
               </sector>"""
     self.loginAsPortalOwner()
     addSurvey(self.portal, survey)
     addSurvey(self.portal, survey_nl)
     browser = Browser()
     browser.open(self.portal.client.absolute_url())
     browser.getLink("Nederlands").click()
     registerUserInClient(browser, link="Registreer")
     self.assertEqual(
             browser.url,
             "http://nohost/plone/client/nl/?language=nl-NL")
     self.assertEqual(browser.getControl(name="survey").options,
             ["branche/vragenlijst"])
     browser.open(
             "%s?language=en" % self.portal.client["nl"].absolute_url())
     self.assertEqual(browser.getControl(name="survey").options,
             ["sector/survey"])
    def testInvalidDateDoesNotBreakRendering(self):
        from euphorie.client import model
        from euphorie.content.tests.utils import BASIC_SURVEY
        from z3c.saconfig import Session

        import datetime

        # Test for http://code.simplon.biz/tracker/tno-euphorie/ticket/150
        self.loginAsPortalOwner()
        addSurvey(self.portal, BASIC_SURVEY)
        survey_url = self.portal.client.nl["ict"][
            "software-development"].absolute_url()
        browser = self.get_browser()
        browser.open(survey_url)
        registerUserInClient(browser)
        # Create a new survey session
        browser.getControl(name="survey").value = ["ict/software-development"]
        browser.getForm(action="new-session").submit()
        browser.getControl(name="form.widgets.title").value = "Sessiøn".encode(
            "utf-8")  # noqa
        # Start the survey
        browser.getControl(name="form.button.submit").click()
        session_url = browser.url.replace("/@@identification", "")
        # Update the risk
        risk = Session.query(model.Risk).first()
        risk.identification = "no"
        risk.action_plans.append(
            model.ActionPlan(
                action_plan="Do something awesome",
                planning_start=datetime.date(1, 2, 3),
            ))
        # Render the report
        browser.handleErrors = False
        browser.open("%s/@@report_view" % session_url)
 def test_surveys_filtered_by_language(self):
     survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                   <title>Sector</title>
                   <survey>
                     <title>Survey</title>
                     <language>en</language>
                   </survey>
                 </sector>"""
     survey_nl = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                 <title>Branche</title>
                 <survey>
                   <title>Vragenlijst</title>
                   <language>nl</language>
                 </survey>
               </sector>"""  # noqa
     self.loginAsPortalOwner()
     addSurvey(self.portal, survey)
     addSurvey(self.portal, survey_nl)
     browser = self.get_browser()
     # Pass the language as URL parameter to ensure that we get the NL
     # version
     browser.open("%s?language=nl" % self.portal.client.absolute_url())
     registerUserInClient(browser, link="Registreer")
     # Note, this used to test that the URL was that of the client,
     # in the correct country (nl), with `?language=nl-NL` appended.
     # I don't see where in the code this language URL parameter would
     # come from, so I remove it in this test as well.
     self.assertEqual(browser.url, "http://nohost/plone/client/nl")
     self.assertEqual(
         browser.getControl(name="survey").options,
         ["", "branche/vragenlijst"])
     browser.open("%s?language=en" %
                  self.portal.client["nl"].absolute_url())
     self.assertEqual(
         browser.getControl(name="survey").options, ["", "sector/survey"])
Example #10
0
 def test_set_unknown_answer_if_skipped(self):
     from euphorie.content.tests.utils import BASIC_SURVEY
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     # Register in the client
     browser = Browser()
     survey_url = self.portal.client.nl['ict']['software-development']\
             .absolute_url()
     browser.open(survey_url)
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name='title:utf8:ustring').value = u'Session'
     browser.getControl(name='next').click()
     # Start the survey
     browser.getForm().submit()
     browser.getLink('Start Risk Identification').click()
     browser.getControl('next').click()
     # No answer should be set on initial view
     self.assertEqual(browser.getControl(name='answer').value, [])
     # Do not give an identification answer
     risk_url = browser.url
     browser.getControl('next').click()
     # Go back and check the new answer
     browser.open(risk_url)
     self.assertTrue(
         'class="current postponed'
         in browser.contents)
Example #11
0
    def testShowFrenchEvaluation(self):
        from euphorie.content.tests.utils import BASIC_SURVEY

        # Test for http://code.simplon.biz/tracker/tno-euphorie/ticket/150
        self.loginAsPortalOwner()
        addSurvey(self.portal, BASIC_SURVEY)
        browser = Browser()
        survey = self.portal.client.nl["ict"]["software-development"]
        survey.evaluation_algorithm = "french"
        survey["1"]["2"].type = "risk"
        browser.open(survey.absolute_url())
        registerUserInClient(browser)
        # Create a new survey session
        browser.getControl(name="title:utf8:ustring").value = "Sessiøn".encode("utf-8")
        browser.getControl(name="next").click()
        # Start the survey
        browser.getForm().submit()
        browser.getLink("Start Risk Identification").click()
        # Identify the risk
        browser.getControl("next").click()
        browser.getControl(name="answer").value = ["no"]
        # Verify number of options
        self.assertEqual(len(browser.getControl(name="frequency:int").controls), 4)
        self.assertEqual(len(browser.getControl(name="severity:int").controls), 4)
        # # Enter some digits
        browser.getControl(name="frequency:int").value = ["7"]
        browser.getControl(name="severity:int").value = ["10"]
        browser.getControl("next").click()
        browser.open(
            "http://nohost/plone/client/nl/ict/software-development/actionplan/1/1"
        )
        self.assertEqual(browser.getControl(name="priority").value, ["high"])
Example #12
0
 def setUp(self):
     super(AccountDeleteTests, self).setUp()
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     survey = self.portal.client["nl"]["ict"]["software-development"]
     self.browser = self.get_browser()
     self.browser.open(survey.absolute_url())
     registerUserInClient(self.browser)
Example #13
0
    def createClientBrowser(self):
        from euphorie.client.tests.utils import registerUserInClient
        from Products.Five.testbrowser import Browser

        browser = Browser()
        browser.open(self.portal.client.nl["ict"]
                     ["software-development"].absolute_url())
        registerUserInClient(browser)
        return browser
Example #14
0
 def setUp(self):
     super(NewEmailTests, self).setUp()
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     survey = self.portal.client["nl"]["ict"]["software-development"]
     self.browser = self.get_browser()
     self.browser.open(survey.absolute_url())
     registerUserInClient(self.browser)
     self._mail_fixture = MockMailFixture()
     self.email_send = self._mail_fixture.storage
Example #15
0
 def setUp(self):
     from Products.Five.testbrowser import Browser
     from euphorie.client.tests.utils import addSurvey
     from euphorie.client.tests.utils import registerUserInClient
     from euphorie.content.tests.utils import BASIC_SURVEY
     super(AccountDeleteTests, self).setUp()
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     survey = self.portal.client["nl"]["ict"]["software-development"]
     self.browser = Browser()
     self.browser.open(survey.absolute_url())
     registerUserInClient(self.browser)
 def test_must_select_valid_survey(self):
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     browser = self.get_browser()
     browser.open(self.portal.client["nl"].absolute_url())
     registerUserInClient(browser, link="Register")
     data = urlencode({
         "action": "new",
         "survey": "",
         "title:utf8:ustring": "Foo"
     })
     browser.handleErrors = False
     browser.open(browser.url, data)
     self.assertEqual(browser.url, "http://nohost/plone/client/nl")
Example #17
0
 def setUp(self):
     from Products.Five.testbrowser import Browser
     from euphorie.client.tests.utils import addSurvey
     from euphorie.client.tests.utils import registerUserInClient
     from euphorie.client.tests.utils import MockMailFixture
     from euphorie.content.tests.utils import BASIC_SURVEY
     super(NewEmailTests, self).setUp()
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     survey = self.portal.client["nl"]["ict"]["software-development"]
     self.browser = Browser()
     self.browser.open(survey.absolute_url())
     registerUserInClient(self.browser)
     self._mail_fixture = MockMailFixture()
     self.email_send = self._mail_fixture.storage
 def test_must_select_valid_survey(self):
     import urllib
     from euphorie.client.tests.utils import registerUserInClient
     from euphorie.content.tests.utils import BASIC_SURVEY
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     browser = Browser()
     browser.open(self.portal.client['nl'].absolute_url())
     registerUserInClient(browser)
     data = urllib.urlencode({'action': 'new',
                              'survey': '',
                              'title:utf8:ustring': 'Foo'})
     browser.handleErrors = False
     browser.open(browser.url, data)
     self.assertEqual(browser.url, 'http://nohost/plone/client/nl')
    def testMultiProfiles(self):
        # Tests http://code.simplon.biz/tracker/euphorie/ticket/96
        survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                      <title>Sector title</title>
                      <survey>
                        <title>Survey title</title>
                        <language>nl</language>
                        <profile-question>
                          <title>Multiple profile question</title>
                          <question>Profile titles</question>
                          <description>&lt;p&gt;Profile description.&lt;/p&gt;</description>
                          <risk type="policy">
                            <title>Profile risk</title>
                            <description>&lt;p&gt;Risk description.&lt;/p&gt;</description>
                            <evaluation-method>direct</evaluation-method>
                          </risk>
                        </profile-question>
                        <module optional="false">
                          <title>Module title</title>
                          <description>&lt;p&gt;Module description.&lt;/p&gt;</description>
                          <risk type="policy">
                            <title>Module risk</title>
                            <description>&lt;p&gt;Module description.&lt;/p&gt;</description>
                            <evaluation-method>direct</evaluation-method>
                          </risk>
                        </module>
                      </survey>
                    </sector>"""  # noqa: E501

        self.loginAsPortalOwner()
        addSurvey(self.portal, survey)
        browser = self.get_browser()
        browser.open(self.portal.client.nl["sector-title"]
                     ["survey-title"].absolute_url())
        registerUserInClient(browser)
        # Create a new survey session
        browser.getControl(name="survey").value = ["sector-title/survey-title"]
        browser.getForm(action="new-session").submit()
        browser.getControl(name="form.widgets.title").value = "Test session"
        # Start the survey
        browser.getControl(name="form.button.submit").click()
        # Enter the profile information
        browser.getControl(name="1:utf8:utext:list",
                           index=0).value = "Profile 1"
        browser.getControl(name="1:utf8:utext:list",
                           index=1).value = "Profile 2"
        browser.getForm(id="profile-form").submit()
Example #20
0
 def test_must_select_valid_survey(self):
     import urllib
     from euphorie.client.tests.utils import registerUserInClient
     from euphorie.content.tests.utils import BASIC_SURVEY
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     browser = Browser()
     browser.open(self.portal.client['nl'].absolute_url())
     registerUserInClient(browser)
     data = urllib.urlencode({
         'action': 'new',
         'survey': '',
         'title:utf8:ustring': 'Foo'
     })
     browser.handleErrors = False
     browser.open(browser.url, data)
     self.assertEqual(browser.url, 'http://nohost/plone/client/nl')
    def testCompanySettingsRoundTrip(self):
        from euphorie.content.tests.utils import BASIC_SURVEY

        self.loginAsPortalOwner()
        addSurvey(self.portal, BASIC_SURVEY)
        browser = self.get_browser()
        survey_url = self.portal.client.nl["ict"][
            "software-development"].absolute_url()
        browser.open(survey_url)
        registerUserInClient(browser)
        # Create a new survey session
        browser.getControl(name="survey").value = ["ict/software-development"]
        browser.getForm(action="new-session").submit()
        browser.getControl(name="form.widgets.title").value = "Sessiøn".encode(
            "utf-8")  # noqa
        # Start the survey
        browser.getControl(name="form.button.submit").click()
        session_url = browser.url.replace("/@@identification", "")
        # Enter some company data
        browser.open("%s/@@report_company" % session_url)
        browser.getControl(name="form.widgets.country").value = ["be"]
        browser.getControl(name="form.widgets.employees").value = ["50-249"]
        browser.getControl(name="form.widgets.conductor").value = ["staff"]
        browser.getControl(name="form.widgets.referer").value = ["trade-union"]
        browser.getControl(name="form.widgets.workers_participated").value = [
            "True"
        ]
        browser.getControl(name="form.buttons.next").click()
        # Make sure all fields validated
        self.assertEqual(browser.url, "%s/@@report_view" % session_url)
        # Verify entered data
        browser.open("%s/@@report_company" % session_url)
        self.assertEqual(
            browser.getControl(name="form.widgets.country").value, ["be"])
        self.assertEqual(
            browser.getControl(name="form.widgets.employees").value,
            ["50-249"])
        self.assertEqual(
            browser.getControl(name="form.widgets.conductor").value, ["staff"])
        self.assertEqual(
            browser.getControl(name="form.widgets.referer").value,
            ["trade-union"])
        self.assertEqual(
            browser.getControl(name="form.widgets.workers_participated").value,
            ["True"])
Example #22
0
 def XtestPreventEarlyDate(self):
     """
     Deactivated until we decide what to do about this kind of validation
     error check
     """
     # Test for http://code.simplon.biz/tracker/tno-euphorie/ticket/150
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     browser = self.get_browser()
     survey_url = self.portal.client.nl["ict"][
         "software-development"].absolute_url()  # noqa: E501
     browser.open(survey_url)
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="survey").value = ["ict/software-development"]
     browser.getForm(action="new-session").submit()
     browser.getControl(name="form.widgets.title").value = "Sessiøn".encode(
         "utf-8")  # noqa
     # Start the survey
     browser.getControl(name="form.button.submit").click()
     # Identify the risk
     browser.getControl("next").click()
     browser.getControl(name="answer").value = ["no"]
     browser.getControl("next").click()
     # Move on to the risk's action plan form
     browser.getLink("Create action plan").click()
     browser.getLink("Next").click()
     # Try an early year
     browser.getControl(name="measure.action_plan:utf8:ustring:records",
                        index=0).value = "Do something awesome"
     browser.getControl(name="measure.planning_start_day:records",
                        index=0).value = "1"
     browser.getControl(name="measure.planning_start_month:records",
                        index=0).value = ["2"]
     browser.getControl(name="measure.planning_start_year:records",
                        index=0).value = "3"
     browser.getControl("next").click()
     self.assertEqual(
         browser.url,
         "http://nohost/plone/client/nl/ict/"
         "software-development/actionplan/1/1",
     )
     self.assertTrue(
         "Please enter a year between 2000 and 2100" in browser.contents)
Example #23
0
 def testCompanySettingsRoundTrip(self):
     from euphorie.content.tests.utils import BASIC_SURVEY
     from euphorie.client.tests.utils import addSurvey
     from euphorie.client.tests.utils import registerUserInClient
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     browser = Browser()
     survey_url = \
         self.portal.client.nl["ict"]["software-development"].absolute_url()
     browser.open(survey_url)
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="title:utf8:ustring").value = \
         u"Sessiøn".encode("utf-8")
     browser.getControl(name="next").click()
     # Start the survey
     browser.getForm().submit()
     browser.getLink("Start Risk Identification").click()
     # Enter some company data
     browser.open("%s/report/company" % survey_url)
     browser.getControl(name="form.widgets.country").value = ["be"]
     browser.getControl(name="form.widgets.employees").value = ["50-249"]
     browser.getControl(name="form.widgets.conductor").value = ["staff"]
     browser.getControl(name="form.widgets.referer").value = ["trade-union"]
     browser.getControl(name="form.widgets.workers_participated").value = \
         ['True']
     browser.getControl(name="form.buttons.next").click()
     # Make sure all fields validated
     self.assertEqual(browser.url, "%s/report/view" % survey_url)
     # Verify entered data
     browser.open("%s/report/company" % survey_url)
     self.assertEqual(
         browser.getControl(name="form.widgets.country").value, ["be"])
     self.assertEqual(
         browser.getControl(name="form.widgets.employees").value,
         ["50-249"])
     self.assertEqual(
         browser.getControl(name="form.widgets.conductor").value, ["staff"])
     self.assertEqual(
         browser.getControl(name="form.widgets.referer").value,
         ["trade-union"])
     self.assertEqual(
         browser.getControl(name="form.widgets.workers_participated").value,
         ["True"])
 def test_top5_skipped_in_evaluation(self):
     # Test for http://code.simplon.biz/tracker/euphorie/ticket/105
     survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                   <title>Sector title</title>
                   <survey>
                     <title>Survey title</title>
                     <evaluation-optional>false</evaluation-optional>
                     <module optional="false">
                       <title>Top5 parent</title>
                       <description>&lt;p&gt;Een module met een top-5 risico.&lt;/p&gt;</description>
                       <risk type="top5">
                         <title>Top-5 probleem!</title>
                         <problem-description>Er is een top-5 probleem.</problem-description>
                         <description>&lt;p&gt;Zomaar wat tekst.&lt;/p&gt;</description>
                         <show-not-applicable>false</show-not-applicable>
                       </risk>
                     </module>
                   </survey>
                 </sector>"""
     self.loginAsPortalOwner()
     addSurvey(self.portal, survey)
     browser = Browser()
     browser.open(self.portal.client.nl["sector-title"]["survey-title"]
             .absolute_url())
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="title:utf8:ustring").value = "Test session"
     browser.getControl(name="next", index=1).click()
     # Start the survey
     browser.getForm().submit()
     browser.getLink("Start Risk Identification").click()
     # Identify the top-5 risk
     browser.open("http://nohost/plone/client/nl/sector-title/"
                     "survey-title/identification/1/1")
     browser.getControl(name="answer").value = ["no"]
     browser.getControl(name="next", index=1).click()
     # Check what the evaluation found
     self.assertEqual(
             browser.url,
             "http://nohost/plone/client/nl/sector-title/"
             "survey-title/evaluation")
     self.assertTrue(
             "There are no risks that need to be evaluated"
             in browser.contents)
Example #25
0
 def testCompanySettingsRoundTrip(self):
     from euphorie.content.tests.utils import BASIC_SURVEY
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     browser = Browser()
     survey_url = self.portal.client.nl["ict"]["software-development"]\
             .absolute_url()
     browser.open(survey_url)
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="title:utf8:ustring").value = \
             u"Sessiøn".encode("utf-8")
     browser.getControl(name="next").click()
     # Start the survey
     browser.getForm().submit()
     browser.getLink("Start Risk Identification").click()
     # Enter some company data
     browser.open("%s/report/company" % survey_url)
     browser.getControl(name="form.widgets.country").value = ["be"]
     browser.getControl(name="form.widgets.employees").value = ["50-249"]
     browser.getControl(name="form.widgets.conductor").value = ["staff"]
     browser.getControl(name="form.widgets.referer").value = ["trade-union"]
     browser.getControl(name="form.widgets.workers_participated")\
             .value = ['True']
     browser.getControl(name="form.buttons.next").click()
     # Make sure all fields validated
     self.assertEqual(browser.url, "%s/report/view" % survey_url)
     # Verify entered data
     browser.open("%s/report/company" % survey_url)
     self.assertEqual(
             browser.getControl(name="form.widgets.country").value, ["be"])
     self.assertEqual(
             browser.getControl(name="form.widgets.employees").value,
             ["50-249"])
     self.assertEqual(
             browser.getControl(name="form.widgets.conductor").value,
             ["staff"])
     self.assertEqual(
             browser.getControl(name="form.widgets.referer").value,
             ["trade-union"])
     self.assertEqual(
             browser.getControl(
                 name="form.widgets.workers_participated").value,
             ["True"])
Example #26
0
 def XtestPreventEarlyDate(self):
     """
     Deactivated until we decide what to do about this kind of validation
     error check
     """
     from euphorie.content.tests.utils import BASIC_SURVEY
     # Test for http://code.simplon.biz/tracker/tno-euphorie/ticket/150
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     browser = Browser()
     survey_url = self.portal.client.nl["ict"]["software-development"]\
             .absolute_url()
     browser.open(survey_url)
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="title:utf8:ustring").value = \
             u"Sessiøn".encode("utf-8")
     browser.getControl(name="next").click()
     # Start the survey
     browser.getForm().submit()
     browser.getLink("Start Risk Identification").click()
     # Identify the risk
     browser.getControl("next").click()
     browser.getControl(name="answer").value = ["no"]
     browser.getControl("next").click()
     # Move on to the risk's action plan form
     browser.getLink("Create action plan").click()
     browser.getLink("Next").click()
     # Try an early year
     browser.getControl(name="measure.action_plan:utf8:ustring:records", index=0)\
             .value = "Do something awesome"
     browser.getControl(name="measure.planning_start_day:records", index=0)\
             .value = "1"
     browser.getControl(name="measure.planning_start_month:records", index=0)\
             .value = ["2"]
     browser.getControl(name="measure.planning_start_year:records", index=0)\
             .value = "3"
     browser.getControl("next").click()
     self.assertEqual(browser.url,
             "http://nohost/plone/client/nl/ict/"
             "software-development/actionplan/1/1")
     self.assertTrue(
             "Please enter a year between 2000 and 2100"
             in browser.contents)
    def testMultiProfiles(self):
        # Tests http://code.simplon.biz/tracker/euphorie/ticket/96
        survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                      <title>Sector title</title>
                      <survey>
                        <title>Survey title</title>
                        <profile-question>
                          <title>Multiple profile question</title>
                          <question>Profile titles</question>
                          <description>&lt;p&gt;Profile description.&lt;/p&gt;</description>
                          <risk type="policy">
                            <title>Profile risk</title>
                            <description>&lt;p&gt;Risk description.&lt;/p&gt;</description>
                            <evaluation-method>direct</evaluation-method>
                          </risk>
                        </profile-question>
                        <module optional="false">
                          <title>Module title</title>
                          <description>&lt;p&gt;Module description.&lt;/p&gt;</description>
                          <risk type="policy">
                            <title>Module risk</title>
                            <description>&lt;p&gt;Module description.&lt;/p&gt;</description>
                            <evaluation-method>direct</evaluation-method>
                          </risk>
                        </module>
                      </survey>
                    </sector>"""

        self.loginAsPortalOwner()
        addSurvey(self.portal, survey)
        browser = Browser()
        browser.open(self.portal.client.nl["sector-title"]["survey-title"]
                .absolute_url())
        registerUserInClient(browser)
        # Create a new survey session
        browser.getControl(name="title:utf8:ustring").value = "Test session"
        browser.getControl(name="next", index=1).click()
        # Start the survey
        browser.getForm().submit()
        # Enter the profile information
        browser.getControl(name="1:utf8:utext:list", index=0).value = "Profile 1"
        browser.getControl(name="1:utf8:utext:list", index=1).value = "Profile 2"
        browser.getForm().submit()
 def test_policy_gets_high_priority(self):
     # Test for http://code.simplon.biz/tracker/tno-euphorie/ticket/93
     survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                   <title>Sector title</title>
                   <survey>
                     <title>Survey title</title>
                     <language>nl</language>
                     <evaluation-optional>false</evaluation-optional>
                     <module optional="false">
                       <title>Policy parent</title>
                       <description>&lt;p&gt;Een module met een beleidsrisico.&lt;/p&gt;</description>
                       <risk type="policy">
                         <title>Policy problem!</title>
                         <problem-description>There is a policy problem.</problem-description>
                         <description>&lt;p&gt;Random text.&lt;/p&gt;</description>
                         <show-not-applicable>false</show-not-applicable>
                       </risk>
                     </module>
                   </survey>
                 </sector>"""  # noqa: E501
     self.loginAsPortalOwner()
     addSurvey(self.portal, survey)
     commit()
     self.request.response.setHeader("X-Theme-Disabled", "1")
     browser = self.get_browser()
     url = self.portal.client.nl["sector-title"]["survey-title"].absolute_url()
     browser.open(url)
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="survey").value = ["sector-title/survey-title"]
     browser.getForm(action="new-session").submit()
     browser.getControl(name="form.widgets.title").value = "Test session"
     # Start the survey
     browser.getControl(name="form.button.submit").click()
     session_url = browser.url.replace("/@@identification", "")
     # Identify the risk
     browser.open("%s/1/1/@@identification" % session_url)
     browser.getControl(name="answer").value = ["no"]
     browser.getControl(name="next", index=1).click()
     # Check priority in action plan
     browser.open("%s/1/1/@@actionplan" % session_url)
     self.assertEqual(browser.getControl(name="priority").value, ["high"])
 def test_top5_skipped_in_evaluation(self):
     # Test for http://code.simplon.biz/tracker/euphorie/ticket/105
     survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                   <title>Sector title</title>
                   <survey>
                     <title>Survey title</title>
                     <language>nl</language>
                     <evaluation-optional>false</evaluation-optional>
                     <module optional="false">
                       <title>Top5 parent</title>
                       <description>&lt;p&gt;Een module met een top-5 risico.&lt;/p&gt;</description>
                       <risk type="top5">
                         <title>Top-5 probleem!</title>
                         <problem-description>Er is een top-5 probleem.</problem-description>
                         <description>&lt;p&gt;Zomaar wat tekst.&lt;/p&gt;</description>
                         <show-not-applicable>false</show-not-applicable>
                       </risk>
                     </module>
                   </survey>
                 </sector>"""  # noqa: E501
     self.loginAsPortalOwner()
     addSurvey(self.portal, survey)
     browser = self.get_browser()
     browser.open(
         self.portal.client.nl["sector-title"]["survey-title"].absolute_url()
     )
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="survey").value = ["sector-title/survey-title"]
     browser.getForm(action="new-session").submit()
     browser.getControl(name="form.widgets.title").value = "Test session"
     # Start the survey
     browser.getControl(name="form.button.submit").click()
     session_url = browser.url.replace("/@@identification", "")
     # Identify the top-5 risk
     browser.open("%s/1/1/@@identification" % session_url)
     browser.getControl(name="answer").value = ["no"]
     # No evaluation is necessary
     self.assertIn(
         "De tool heeft automatisch een risico-evaluatie uitgevoerd",
         browser.contents,
     )
Example #30
0
    def testCountryDefaultsToCurrentCountry(self):
        from euphorie.client.tests.utils import addSurvey
        from euphorie.client.tests.utils import registerUserInClient
        from euphorie.content.tests.utils import BASIC_SURVEY

        self.loginAsPortalOwner()
        addSurvey(self.portal, BASIC_SURVEY)
        browser = Browser()
        survey_url = self.portal.client.nl["ict"]["software-development"].absolute_url()
        browser.open(survey_url)
        registerUserInClient(browser)
        # Create a new survey session
        browser.getControl(name="title:utf8:ustring").value = "Sessiøn".encode("utf-8")
        browser.getControl(name="next").click()
        # Start the survey
        browser.getForm().submit()
        browser.getLink("Start Risk Identification").click()
        # Check the company data
        browser.open("%s/report/company" % survey_url)
        self.assertEqual(browser.getControl(name="form.widgets.country").value, ["nl"])
Example #31
0
 def Xtest_do_not_abort_on_far_future(self):
     """
     Deactivated, since such a far-future date can not be entered any more
     in modern browsers
     """
     # Test for http://code.simplon.biz/tracker/tno-euphorie/ticket/150
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     browser = self.get_browser()
     survey_url = self.portal.client.nl["ict"][
         "software-development"].absolute_url()
     browser.open(survey_url)
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="survey").value = ["ict/software-development"]
     browser.getForm(action="new-session").submit()
     browser.getControl(name="form.widgets.title").value = "Sessiøn".encode(
         "utf-8")  # noqa
     # Start the survey
     browser.getControl(name="form.button.submit").click()
     # Identify the risk
     browser.getControl("next").click()
     browser.getControl(name="answer").value = ["no"]
     browser.getControl("next").click()
     # Move on to the risk's action plan form
     browser.getLink("Create action plan").click()
     browser.getLink("Next").click()
     # Try an early year
     browser.getControl(name="measure.action_plan:utf8:ustring:records",
                        index=0).value = "Do something awesome"
     browser.getControl(name="measure.planning_start:records",
                        index=0).value = "12345/02/01"
     browser.handleErrors = False
     browser.getControl("next").click()
     self.assertEqual(
         browser.url,
         "http://nohost/plone/client/nl/ict/"
         "software-development/actionplan/1/1",
     )
     self.assertTrue(
         "Please enter a year between 2000 and 2100" in browser.contents)
Example #32
0
 def Xtest_do_not_abort_on_far_future(self):
     """
     Deactivated, since such a far-future date can not be entered any more
     in modern browsers
     """
     from euphorie.content.tests.utils import BASIC_SURVEY
     # Test for http://code.simplon.biz/tracker/tno-euphorie/ticket/150
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     browser = Browser()
     survey_url = (self.portal.client.nl["ict"]
             ["software-development"].absolute_url())
     browser.open(survey_url)
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="title:utf8:ustring").value = \
             u"Sessiøn".encode("utf-8")
     browser.getControl(name="next").click()
     # Start the survey
     browser.getForm().submit()
     browser.getLink("Start Risk Identification").click()
     # Identify the risk
     browser.getControl("next").click()
     browser.getControl(name="answer").value = ["no"]
     browser.getControl("next").click()
     # Move on to the risk's action plan form
     browser.getLink("Create action plan").click()
     browser.getLink("Next").click()
     # Try an early year
     browser.getControl(name="measure.action_plan:utf8:ustring:records", index=0)\
             .value = "Do something awesome"
     browser.getControl(name="measure.planning_start:records", index=0)\
             .value = "12345/02/01"
     browser.handleErrors = False
     browser.getControl("next").click()
     self.assertEqual(browser.url,
             "http://nohost/plone/client/nl/ict/"
             "software-development/actionplan/1/1")
     self.assertTrue(
             "Please enter a year between 2000 and 2100"
             in browser.contents)
Example #33
0
 def testCountryDefaultsToCurrentCountry(self):
     from euphorie.content.tests.utils import BASIC_SURVEY
     self.loginAsPortalOwner()
     addSurvey(self.portal, BASIC_SURVEY)
     browser = Browser()
     survey_url = self.portal.client.nl["ict"]["software-development"]\
             .absolute_url()
     browser.open(survey_url)
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="title:utf8:ustring").value = \
             u"Sessiøn".encode("utf-8")
     browser.getControl(name="next").click()
     # Start the survey
     browser.getForm().submit()
     browser.getLink("Start Risk Identification").click()
     # Check the company data
     browser.open("%s/report/company" % survey_url)
     self.assertEqual(
             browser.getControl(name="form.widgets.country").value,
             ["nl"])
 def test_policy_gets_high_priority(self):
     # Test for http://code.simplon.biz/tracker/tno-euphorie/ticket/93
     survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                   <title>Sector title</title>
                   <survey>
                     <title>Survey title</title>
                     <evaluation-optional>false</evaluation-optional>
                     <module optional="false">
                       <title>Policy parent</title>
                       <description>&lt;p&gt;Een module met een beleidsrisico.&lt;/p&gt;</description>
                       <risk type="policy">
                         <title>Policy problem!</title>
                         <problem-description>There is a policy problem.</problem-description>
                         <description>&lt;p&gt;Random text.&lt;/p&gt;</description>
                         <show-not-applicable>false</show-not-applicable>
                       </risk>
                     </module>
                   </survey>
                 </sector>"""
     self.loginAsPortalOwner()
     addSurvey(self.portal, survey)
     browser = Browser()
     browser.open(self.portal.client.nl["sector-title"]["survey-title"]
                     .absolute_url())
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="title:utf8:ustring").value = "Test session"
     browser.getControl(name="next").click()
     # Start the survey
     browser.getForm().submit()
     browser.getLink("Start Risk Identification").click()
     # Identify the risk
     browser.open("http://nohost/plone/client/nl/sector-title/"
                  "survey-title/identification/1/1")
     browser.getControl(name="answer").value = ["no"]
     browser.getControl(name="next", index=1).click()
     # Check priority in action plan
     browser.open("http://nohost/plone/client/nl/sector-title/"
                  "survey-title/actionplan/1/1")
     self.assertEqual(browser.getControl(name="priority").value, ["high"])
    def testCountryDefaultsToCurrentCountry(self):
        from euphorie.content.tests.utils import BASIC_SURVEY

        self.loginAsPortalOwner()
        addSurvey(self.portal, BASIC_SURVEY)
        survey_url = self.portal.client.nl["ict"][
            "software-development"].absolute_url()  # noqa: E501
        browser = self.get_browser()
        browser.open(survey_url)
        registerUserInClient(browser)
        # Create a new survey session
        browser.getControl(name="survey").value = ["ict/software-development"]
        browser.getForm(action="new-session").submit()
        browser.getControl(name="form.widgets.title").value = "Sessiøn".encode(
            "utf-8")  # noqa
        # Start the survey
        browser.getControl(name="form.button.submit").click()
        session_url = browser.url.replace("/@@identification", "")
        # Check the company data
        browser.open("%s/@@report_company" % session_url)
        self.assertEqual(
            browser.getControl(name="form.widgets.country").value, ["nl"])
 def test_top5_skipped_in_evaluation(self):
     # Test for http://code.simplon.biz/tracker/euphorie/ticket/105
     survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                   <title>Sector title</title>
                   <survey>
                     <title>Survey title</title>
                     <evaluation-optional>false</evaluation-optional>
                     <module optional="false">
                       <title>Top5 parent</title>
                       <description>&lt;p&gt;Een module met een top-5 risico.&lt;/p&gt;</description>
                       <risk type="top5">
                         <title>Top-5 probleem!</title>
                         <problem-description>Er is een top-5 probleem.</problem-description>
                         <description>&lt;p&gt;Zomaar wat tekst.&lt;/p&gt;</description>
                         <show-not-applicable>false</show-not-applicable>
                       </risk>
                     </module>
                   </survey>
                 </sector>"""
     self.loginAsPortalOwner()
     addSurvey(self.portal, survey)
     browser = Browser()
     browser.open(self.portal.client.nl["sector-title"]["survey-title"]
             .absolute_url())
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="title:utf8:ustring").value = "Test session"
     browser.getControl(name="next").click()
     # Start the survey
     browser.getForm().submit()
     browser.getLink("Start Risk Identification").click()
     # Identify the top-5 risk
     browser.open("http://nohost/plone/client/nl/sector-title/"
                     "survey-title/identification/1/1")
     browser.getControl(name="answer").value = ["no"]
     # No evaluation is necessary
     self.assertTrue(
             "The risk evaluation has been automatically done by the tool"
             in browser.contents)
Example #37
0
 def test_surveys_filtered_by_language(self):
     from euphorie.client.tests.utils import registerUserInClient
     survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                   <title>Sector</title>
                   <survey>
                     <title>Survey</title>
                     <language>en</language>
                   </survey>
                 </sector>"""
     survey_nl = \
             """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                 <title>Branche</title>
                 <survey>
                   <title>Vragenlijst</title>
                   <language>nl</language>
                 </survey>
               </sector>"""
     self.loginAsPortalOwner()
     addSurvey(self.portal, survey)
     addSurvey(self.portal, survey_nl)
     browser = Browser()
     browser.open(self.portal.client.absolute_url())
     browser.getLink("Nederlands").click()
     registerUserInClient(browser, link="Registreer")
     # Note, this used to test that the URL was that of the client,
     # in the correct country (nl), with `?language=nl-NL` appended.
     # I don't see where in the code this language URL parameter would
     # come from, so I remove it in this test as well.
     self.assertEqual(
             browser.url,
             "http://nohost/plone/client/nl")
     browser.getLink(id='button-new-session').click()
     self.assertEqual(browser.getControl(name="survey").options,
             ["branche/vragenlijst"])
     browser.open("%s?language=en" % self.portal.client["nl"].absolute_url())
     browser.getLink(id='button-new-session').click()
     self.assertEqual(browser.getControl(name="survey").options,
             ["sector/survey"])
Example #38
0
 def test_surveys_filtered_by_language(self):
     from euphorie.client.tests.utils import registerUserInClient
     survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                   <title>Sector</title>
                   <survey>
                     <title>Survey</title>
                     <language>en</language>
                   </survey>
                 </sector>"""
     survey_nl = \
             """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                 <title>Branche</title>
                 <survey>
                   <title>Vragenlijst</title>
                   <language>nl</language>
                 </survey>
               </sector>"""
     self.loginAsPortalOwner()
     addSurvey(self.portal, survey)
     addSurvey(self.portal, survey_nl)
     browser = Browser()
     browser.open(self.portal.client.absolute_url())
     browser.getLink("Nederlands").click()
     registerUserInClient(browser, link="Registreer")
     # Note, this used to test that the URL was that of the client,
     # in the correct country (nl), with `?language=nl-NL` appended.
     # I don't see where in the code this language URL parameter would
     # come from, so I remove it in this test as well.
     self.assertEqual(browser.url, "http://nohost/plone/client/nl")
     browser.getLink(id='button-new-session').click()
     self.assertEqual(
         browser.getControl(name="survey").options, ["branche/vragenlijst"])
     browser.open("%s?language=en" %
                  self.portal.client["nl"].absolute_url())
     browser.getLink(id='button-new-session').click()
     self.assertEqual(
         browser.getControl(name="survey").options, ["sector/survey"])
    def XtestUpdateShowsRepeatableProfileItems(self):
        # Tests http://code.simplon.biz/tracker/tno-euphorie/ticket/85
        survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                      <title>Sector title</title>
                      <survey>
                        <title>Survey title</title>
                        <language>nl</language>
                        <profile-question>
                          <title>Multiple profile question</title>
                          <question>Profile titles</question>
                          <description>&lt;p&gt;Profile description.&lt;/p&gt;</description>
                          <risk type="policy">
                            <title>Profile risk</title>
                            <description>&lt;p&gt;Risk description.&lt;/p&gt;</description>
                            <evaluation-method>direct</evaluation-method>
                          </risk>
                        </profile-question>
                      </survey>
                    </sector>"""  # noqa: E501
        self.loginAsPortalOwner()
        addSurvey(self.portal, survey)
        browser = self.get_browser()
        browser.open(self.portal.client.nl["sector-title"]
                     ["survey-title"].absolute_url())
        registerUserInClient(browser)
        # Create a new survey session
        browser.getControl(name="title:utf8:ustring").value = "Test session"
        browser.getControl(name="next", index=1).click()
        # Start the survey
        browser.getForm().submit()
        # Enter the profile information
        browser.getControl(name="1:utext:list", index=0).value = "Profile 1"
        browser.getControl(name="1:utext:list", index=1).value = "Profile 2"
        browser.getForm().submit()
        # Change the survey and publish again
        from euphorie.client import publish

        survey = self.portal.sectors["nl"]["sector-title"]["survey-title"][
            "test-import"]
        survey.invokeFactory("euphorie.module", "test module")
        publisher = publish.PublishSurvey(survey, self.portal.REQUEST)
        publisher.publish()
        # We should get an update notification now
        browser.getLink("Start Risk Identification").click()
        self.assertEqual(
            browser.url,
            "http://nohost/plone/client/nl/sector-title/survey-title/update",
        )
        # And our current profile should be listed
        self.assertEqual(
            browser.getControl(name="1:utext:list", index=0).value,
            "Profile 1")
        self.assertEqual(
            browser.getControl(name="1:utext:list", index=1).value,
            "Profile 2")
        # Confirm the profile
        browser.getForm().submit()
        self.assertEqual(
            browser.url,
            "http://nohost/plone/client/nl/sector-title/"
            "survey-title/identification",
        )
        # Make sure the profile is correct
        browser.getLink("Start Risk Identification").click()
        self.assertTrue("Profile 1" in browser.contents)
        self.assertTrue("Profile 2" in browser.contents)
    def XtestSkipChildrenFalseForMandatoryModules(self):
        """Mandatory modules must have skip_children=False. It's possible that
        the module was optional with skip_children=True and now after the
        update must be mandatory.
        """
        survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                      <title>Sector title</title>
                      <survey>
                          <title>Survey title</title>
                          <language>nl</language>
                          <module optional="true">
                              <title>Module Title</title>
                              <description>&lt;p&gt;Testing ticket #3860&lt;/p&gt;</description>
                              <question>What is the sound of one hand clapping?</question>
                              <risk type="risk">
                                  <title>This risk exists</title>
                                  <problem-description>This risk doesn't exist</problem-description>
                                  <description>&lt;p&gt;asdg&lt;/p&gt;</description>
                                  <show-not-applicable>false</show-not-applicable>
                                  <evaluation-method>direct</evaluation-method>
                              </risk>
                          </module>
                      </survey>
                  </sector>"""  # noqa: E501

        self.loginAsPortalOwner()
        addSurvey(self.portal, survey)
        browser = self.get_browser()
        client_survey = self.portal.client.nl["sector-title"]["survey-title"]
        browser.open(client_survey.absolute_url())
        registerUserInClient(browser)
        # Create a new survey session
        browser.getControl(name="title:utf8:ustring").value = "Test session"
        browser.getControl(name="next", index=1).click()
        # Start the survey
        browser.getForm().submit()
        # Enter the profile information
        browser.getLink("Start Risk Identification").click()
        # Set Skip-children to True
        module_identification_url = browser.url
        browser.handleErrors = False
        # XXX: The following breaks when testing with sqlite but not with
        # postgres.
        browser.getControl(name="skip_children:boolean").controls[1].click()
        browser.getControl(name="next", index=1).click()
        # Change the survey to make the module required and publish again
        from euphorie.client import publish

        survey = self.portal.sectors["nl"]["sector-title"]["survey-title"][
            "test-import"]
        module = survey["1"]
        module.optional = False
        publisher = publish.PublishSurvey(survey, self.portal.REQUEST)
        publisher.publish()

        # We should get an update notification now
        browser.open(client_survey.absolute_url())
        browser.getLink("Start Risk Identification").click()
        # We should now be on the module
        self.assertEqual(browser.url, module_identification_url)
        # But this time, the module's "optional" question (i.e to skip the
        # children) should not be there
        self.assertRaises(LookupError,
                          browser.getControl,
                          name="skip_children:boolean")
        browser.getControl(name="next", index=1).click()
        # Now we must see the risk, i.e skip_children=False so we *must* answer
        # the risk
        self.assertEqual(
            "<legend>This risk exists</legend>" in browser.contents, True)
        # There are 2 inputs (2 radio, 1 hidden), for yes, no and postponed.
        self.assertEqual(len(browser.getControl(name="answer").controls), 3)
        self.assertEqual(
            browser.getControl(name="answer:default").value, "postponed")
    def XtestSkipChildrenFalseForMandatoryModules(self):
        """ Mandatory modules must have skip_children=False. It's possible that
            the module was optional with skip_children=True and now after the
            update must be mandatory.
        """
        survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                      <title>Sector title</title>
                      <survey>
                          <title>Survey title</title>
                          <module optional="true">
                              <title>Module Title</title>
                              <description>&lt;p&gt;Testing ticket #3860&lt;/p&gt;</description>
                              <question>What is the sound of one hand clapping?</question>
                              <risk type="risk">
                                  <title>This risk exists</title>
                                  <problem-description>This risk doesn't exist</problem-description>
                                  <description>&lt;p&gt;asdg&lt;/p&gt;</description>
                                  <show-not-applicable>false</show-not-applicable>
                                  <evaluation-method>direct</evaluation-method>
                              </risk>
                          </module>
                      </survey>
                  </sector>"""

        self.loginAsPortalOwner()
        addSurvey(self.portal, survey)
        browser = Browser()
        client_survey = self.portal.client.nl["sector-title"]["survey-title"]
        browser.open(client_survey.absolute_url())
        registerUserInClient(browser)
        # Create a new survey session
        browser.getControl(name="title:utf8:ustring").value = "Test session"
        browser.getControl(name="next", index=1).click()
        # Start the survey
        browser.getForm().submit()
        # Enter the profile information
        browser.getLink("Start Risk Identification").click()
        # Set Skip-children to True
        module_identification_url = browser.url
        browser.handleErrors = False
        # XXX: The following breaks when testing with sqlite but not with
        # postgres.
        browser.getControl(name="skip_children:boolean").controls[1].click()
        browser.getControl(name="next", index=1).click()
        # Change the survey to make the module required and publish again
        from euphorie.client import publish
        survey = self.portal.sectors["nl"]["sector-title"]["survey-title"]["test-import"]
        module = survey['1']
        module.optional = False
        publisher = publish.PublishSurvey(survey, self.portal.REQUEST)
        publisher.publish()

        # We should get an update notification now
        browser.open(client_survey.absolute_url())
        browser.getLink("Start Risk Identification").click()
        # We should now be on the module
        self.assertEqual(browser.url, module_identification_url)
        # But this time, the module's "optional" question (i.e to skip the
        # children) should not be there
        self.assertRaises(LookupError,
                browser.getControl, name='skip_children:boolean')
        browser.getControl(name="next", index=1).click()
        # Now we must see the risk, i.e skip_children=False so we *must* answer
        # the risk
        self.assertEqual(
                "<legend>This risk exists</legend>" in browser.contents, True)
        # There are 2 inputs (2 radio, 1 hidden), for yes, no and postponed.
        self.assertEqual(len(browser.getControl(name="answer").controls), 3)
        self.assertEqual(
                browser.getControl(name="answer:default").value, 'postponed')
 def XtestUpdateShowsRepeatableProfileItems(self):
     # Tests http://code.simplon.biz/tracker/tno-euphorie/ticket/85
     survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
                   <title>Sector title</title>
                   <survey>
                     <title>Survey title</title>
                     <profile-question>
                       <title>Multiple profile question</title>
                       <question>Profile titles</question>
                       <description>&lt;p&gt;Profile description.&lt;/p&gt;</description>
                       <risk type="policy">
                         <title>Profile risk</title>
                         <description>&lt;p&gt;Risk description.&lt;/p&gt;</description>
                         <evaluation-method>direct</evaluation-method>
                       </risk>
                     </profile-question>
                   </survey>
                 </sector>"""
     self.loginAsPortalOwner()
     addSurvey(self.portal, survey)
     browser = Browser()
     browser.open(self.portal.client.nl["sector-title"]["survey-title"]
                     .absolute_url())
     registerUserInClient(browser)
     # Create a new survey session
     browser.getControl(name="title:utf8:ustring").value = "Test session"
     browser.getControl(name="next", index=1).click()
     # Start the survey
     browser.getForm().submit()
     # Enter the profile information
     browser.getControl(name="1:utext:list", index=0).value = "Profile 1"
     browser.getControl(name="1:utext:list", index=1).value = "Profile 2"
     browser.getForm().submit()
     # Change the survey and publish again
     from euphorie.client import publish
     survey = (self.portal.sectors["nl"]["sector-title"]
                     ["survey-title"]["test-import"])
     survey.invokeFactory("euphorie.module", "test module")
     publisher = publish.PublishSurvey(survey, self.portal.REQUEST)
     publisher.publish()
     # We should get an update notification now
     browser.getLink("Start Risk Identification").click()
     self.assertEqual(
             browser.url,
             "http://nohost/plone/client/nl/sector-title/survey-title/update")
     # And our current profile should be listed
     self.assertEqual(
             browser.getControl(name="1:utext:list", index=0).value,
             "Profile 1")
     self.assertEqual(
             browser.getControl(name="1:utext:list", index=1).value,
             "Profile 2")
     # Confirm the profile
     browser.getForm().submit()
     self.assertEqual(
             browser.url,
             "http://nohost/plone/client/nl/sector-title/"
             "survey-title/identification")
     # Make sure the profile is correct
     browser.getLink("Start Risk Identification").click()
     self.assertTrue("Profile 1" in browser.contents)
     self.assertTrue("Profile 2" in browser.contents)