Esempio n. 1
0
def test_view_submitted_response_not_expired(fake_session_data, app: Flask):
    with app.app_context():
        context = build_thank_you_context(SCHEMA, fake_session_data,
                                          SUBMITTED_AT, SURVEY_TYPE_DEFAULT)

        assert context["view_submitted_response"]["expired"] is False
        assert context["view_submitted_response"][
            "url"] == "/submitted/view-response/"
Esempio n. 2
0
def test_view_submitted_response_expired(fake_session_data, app: Flask):
    submitted_at = SUBMITTED_AT - timedelta(minutes=46)

    with app.app_context():
        context = build_thank_you_context(SCHEMA, fake_session_data,
                                          submitted_at, SURVEY_TYPE_DEFAULT)

        assert context["view_submitted_response"]["expired"] is True
Esempio n. 3
0
def test_view_submitted_response_not_enabled(fake_session_data, app: Flask):
    with app.app_context():
        schema = load_schema_from_name("test_title", "en")

        context = build_thank_you_context(schema, fake_session_data,
                                          SUBMITTED_AT, SURVEY_TYPE_DEFAULT)

        assert context["view_submitted_response"]["enabled"] is False
Esempio n. 4
0
def test_social_survey_context(fake_session_data, app: Flask):
    with app.app_context():
        context = build_thank_you_context(SCHEMA, fake_session_data,
                                          SUBMITTED_AT, SURVEY_TYPE_SOCIAL)

        assert context[
            "submission_text"] == "Your answers have been submitted."
        assert len(context["metadata"]["itemsList"]) == 1
Esempio n. 5
0
def test_default_survey_context(fake_session_data, app: Flask):
    with app.app_context():
        fake_session_data.ru_name = "ESSENTIAL ENTERPRISE LTD"
        context = build_thank_you_context(SCHEMA, fake_session_data,
                                          SUBMITTED_AT, SURVEY_TYPE_DEFAULT)

        assert (
            context["submission_text"] ==
            "Your answers have been submitted for <span>ESSENTIAL ENTERPRISE LTD</span>"
        )
        assert len(context["metadata"]["itemsList"]) == 2
Esempio n. 6
0
def test_custom_guidance(fake_session_data, app: Flask):
    with app.app_context():
        custom_guidance = {"contents": [{"description": "Custom guidance"}]}
        context = build_thank_you_context(
            SCHEMA,
            fake_session_data,
            SUBMITTED_AT,
            SURVEY_TYPE_DEFAULT,
            custom_guidance,
        )

        assert context["guidance"] == custom_guidance
    def get_context(self):
        if not self._is_census_theme:
            guidance_content = self._schema.get_post_submission().get(
                "guidance")
            return build_thank_you_context(
                self._schema,
                self._session_store.session_data,
                self._submitted_at,
                get_survey_type(),
                guidance_content,
            )

        confirmation_email_form = (self.confirmation_email.form
                                   if self.confirmation_email else None)

        return build_census_thank_you_context(
            self._session_store.session_data,
            confirmation_email_form,
            self._schema.form_type,
        )
Esempio n. 8
0
def test_view_submitted_response_enabled(fake_session_data, app: Flask):
    with app.app_context():
        context = build_thank_you_context(SCHEMA, fake_session_data,
                                          SUBMITTED_AT, SURVEY_TYPE_DEFAULT)

        assert context["view_submitted_response"]["enabled"] is True