def test_titles_for_repeating_section_summary(people_answer_store):
    schema = load_schema_from_name(
        "test_repeating_sections_with_hub_and_spoke")

    section_summary_context = SectionSummaryContext(
        DEFAULT_LANGUAGE_CODE,
        schema,
        people_answer_store,
        ListStore([
            {
                "items": ["PlwgoG", "UHPLbX"],
                "name": "people"
            },
            {
                "items": ["gTrlio"],
                "name": "visitors"
            },
        ]),
        ProgressStore(),
        {},
        current_location=Location(
            section_id="personal-details-section",
            list_name="people",
            list_item_id="PlwgoG",
        ),
        routing_path=MagicMock(),
    )

    context = section_summary_context()

    assert context["summary"]["title"] == "Toni Morrison"

    section_summary_context = SectionSummaryContext(
        DEFAULT_LANGUAGE_CODE,
        schema,
        people_answer_store,
        ListStore([
            {
                "items": ["PlwgoG", "UHPLbX"],
                "name": "people"
            },
            {
                "items": ["gTrlio"],
                "name": "visitors"
            },
        ]),
        ProgressStore(),
        {},
        current_location=Location(
            block_id="personal-summary",
            section_id="personal-details-section",
            list_name="people",
            list_item_id="UHPLbX",
        ),
        routing_path=MagicMock(),
    )

    context = section_summary_context()
    assert context["summary"]["title"] == "Barry Pheloung"
def test_primary_links_for_section_summary(people_answer_store):
    schema = load_schema_from_name("test_list_collector_section_summary")

    summary_context = SectionSummaryContext(
        language=DEFAULT_LANGUAGE_CODE,
        schema=schema,
        answer_store=people_answer_store,
        list_store=ListStore(
            [
                {
                    "items": ["PlwgoG", "fg0sPd"],
                    "name": "people",
                    "primary_person": "PlwgoG",
                }
            ]
        ),
        progress_store=ProgressStore(),
        metadata={"display_address": "70 Abingdon Road, Goathill"},
        response_metadata={},
        current_location=Location(section_id="section"),
        routing_path=RoutingPath(
            [
                "primary-person-list-collector",
                "list-collector",
                "visitor-list-collector",
            ],
            section_id="section",
        ),
    )
    context = summary_context()

    list_items = context["summary"]["custom_summary"][0]["list"]["list_items"]

    assert "/edit-person/" in list_items[0]["edit_link"]
    assert "/edit-person/" in list_items[1]["edit_link"]
Exemplo n.º 3
0
 def context(self):
     section_summary_context = SectionSummaryContext(
         self._language,
         self._schema,
         self._questionnaire_store.answer_store,
         self._questionnaire_store.list_store,
         self._questionnaire_store.progress_store,
         self._questionnaire_store.metadata,
     )
     return section_summary_context(self.current_location)
Exemplo n.º 4
0
 def get_context(self):
     section_summary_context = SectionSummaryContext(
         self._language,
         self._schema,
         self._questionnaire_store.answer_store,
         self._questionnaire_store.list_store,
         self._questionnaire_store.progress_store,
         self._questionnaire_store.metadata,
         self._questionnaire_store.response_metadata,
         self._routing_path,
         self.current_location,
     )
     return section_summary_context()
Exemplo n.º 5
0
 def test_section_summary_title_is_section_title(self):
     current_location = Location(section_id="property-details-section")
     summary_context = SectionSummaryContext(
         self.language,
         self.schema,
         self.answer_store,
         self.progress_store,
         self.list_store,
         self.metadata,
     )
     context = summary_context(current_location)
     self.assertEqual(context["summary"]["title"],
                      "Property Details Section")
Exemplo n.º 6
0
 def test_custom_section_summary_page_title(self):
     current_location = Location(section_id="property-details-section")
     summary_context = SectionSummaryContext(
         self.language,
         self.schema,
         AnswerStore([]),
         self.list_store,
         self.progress_store,
         self.metadata,
     )
     context = summary_context(current_location)
     self.assertEqual("Custom section summary title",
                      context["summary"]["page_title"])
Exemplo n.º 7
0
 def test_section_summary_page_title_placeholder_text_plural_replaced(self):
     current_location = Location(section_id="household-count-section")
     answers = [{"answer_id": "number-of-people-answer", "value": 3}]
     summary_context = SectionSummaryContext(
         self.language,
         self.schema,
         AnswerStore(answers),
         self.list_store,
         self.progress_store,
         self.metadata,
     )
     context = summary_context(current_location)
     self.assertEqual(context["summary"]["page_title"],
                      "… people live here")
Exemplo n.º 8
0
 def test_section_summary_title_is_section_title(self):
     summary_context = SectionSummaryContext(
         self.language,
         self.schema,
         self.answer_store,
         self.list_store,
         self.progress_store,
         self.metadata,
         self.response_metadata,
         routing_path=MagicMock(),
         current_location=Location(section_id="property-details-section"),
     )
     context = summary_context()
     self.assertEqual(context["summary"]["title"], "Property Details Section")
Exemplo n.º 9
0
    def test_build_summary_rendering_context(self):
        section_summary_context = SectionSummaryContext(
            self.language,
            self.schema,
            self.answer_store,
            self.progress_store,
            self.list_store,
            self.metadata,
        )

        single_section_context = section_summary_context(
            Location(section_id="property-details-section"))

        self.check_summary_rendering_context(single_section_context)
    def test_build_summary_rendering_context(self):
        section_summary_context = SectionSummaryContext(
            self.language,
            self.schema,
            self.answer_store,
            self.list_store,
            self.progress_store,
            self.metadata,
            current_location=Location(section_id="property-details-section"),
            routing_path=MagicMock(),
        )

        single_section_context = section_summary_context()

        self.assert_summary_context(single_section_context)
Exemplo n.º 11
0
 def test_section_summary_page_title_placeholder_text_replaced(self):
     answers = [{"answer_id": "house-type-answer", "value": "Semi-detached"}]
     summary_context = SectionSummaryContext(
         self.language,
         self.schema,
         AnswerStore(answers),
         self.progress_store,
         self.list_store,
         self.metadata,
         self.response_metadata,
         current_location=Location(section_id="house-details-section"),
         routing_path=MagicMock(),
     )
     context = summary_context()
     self.assertEqual(context["summary"]["page_title"], "Household Summary - …")
def test_context_for_driving_question_summary_empty_list():
    schema = load_schema_from_name("test_list_collector_driving_question")

    summary_context = SectionSummaryContext(
        DEFAULT_LANGUAGE_CODE,
        schema,
        AnswerStore([{
            "answer_id": "anyone-usually-live-at-answer",
            "value": "No"
        }]),
        ListStore(),
        ProgressStore(),
        {},
        current_location=Location(section_id="section"),
        routing_path=RoutingPath(["anyone-usually-live-at"],
                                 section_id="section"),
    )

    context = summary_context()
    expected = {
        "summary": {
            "answers_are_editable":
            True,
            "collapsible":
            False,
            "custom_summary": [{
                "add_link":
                "/questionnaire/anyone-usually-live-at/?return_to=section-summary",
                "add_link_text": "Add someone to this household",
                "empty_list_text": "There are no householders",
                "list": {
                    "editable": False,
                    "list_items": []
                },
                "list_name": "people",
                "title": "Household members",
                "type": "List",
            }],
            "page_title":
            "List Collector Driving Question Summary",
            "summary_type":
            "SectionSummary",
            "title":
            "List Collector Driving Question Summary",
        }
    }

    assert context == expected
Exemplo n.º 13
0
 def test_custom_setion_summary_title(self):
     current_location = Location(section_id="house-details-section")
     answers = [{
         "answer_id": "house-type-answer",
         "value": "Semi-detached"
     }]
     summary_context = SectionSummaryContext(
         self.language,
         self.schema,
         AnswerStore(answers),
         self.list_store,
         self.progress_store,
         self.metadata,
     )
     context = summary_context(current_location)
     self.assertEqual("Household Summary - Semi-detached",
                      context["summary"]["title"])
Exemplo n.º 14
0
    def test_build_view_context_for_section_summary(self):
        current_location = Location(section_id="property-details-section",
                                    block_id="property-details-summary")

        summary_context = SectionSummaryContext(
            self.language,
            self.schema,
            self.answer_store,
            self.progress_store,
            self.list_store,
            self.metadata,
        )
        context = summary_context(current_location)

        self.check_context(context)
        self.check_summary_rendering_context(context)
        self.assertEqual(len(context["summary"]), 6)
        self.assertTrue("title" in context["summary"])
Exemplo n.º 15
0
def test_primary_only_links_for_section_summary(people_answer_store):
    schema = load_schema_from_name("test_list_collector_section_summary")
    current_location = Location(section_id="section")

    summary_context = SectionSummaryContext(
        language=DEFAULT_LANGUAGE_CODE,
        schema=schema,
        answer_store=people_answer_store,
        list_store=ListStore([{
            "items": ["PlwgoG"],
            "name": "people",
            "primary_person": "PlwgoG"
        }]),
        progress_store=ProgressStore(),
        metadata={"display_address": "70 Abingdon Road, Goathill"},
    )
    context = summary_context(current_location)

    list_items = context["summary"]["custom_summary"][0]["list"]["list_items"]

    assert "/add-or-edit-primary-person/" in list_items[0]["edit_link"]
Exemplo n.º 16
0
    def test_build_view_context_for_section_summary(self):
        summary_context = SectionSummaryContext(
            self.language,
            self.schema,
            self.answer_store,
            self.list_store,
            self.progress_store,
            self.metadata,
            self.response_metadata,
            current_location=Location(
                section_id="property-details-section",
                block_id="property-details-summary",
            ),
            routing_path=MagicMock(),
        )
        context = summary_context()

        self.assertIn("summary", context)
        self.assert_summary_context(context)
        self.assertEqual(len(context["summary"]), 6)
        self.assertTrue("title" in context["summary"])
Exemplo n.º 17
0
def test_context_for_driving_question_summary():
    schema = load_schema_from_name("test_list_collector_driving_question")
    current_location = Location(section_id="section")

    summary_context = SectionSummaryContext(
        DEFAULT_LANGUAGE_CODE,
        schema,
        AnswerStore([
            {
                "answer_id": "anyone-usually-live-at-answer",
                "value": "Yes"
            },
            {
                "answer_id": "first-name",
                "value": "Toni",
                "list_item_id": "PlwgoG"
            },
            {
                "answer_id": "last-name",
                "value": "Morrison",
                "list_item_id": "PlwgoG",
            },
        ]),
        ListStore([{
            "items": ["PlwgoG"],
            "name": "people"
        }]),
        ProgressStore(),
        {},
    )

    context = summary_context(current_location)

    expected = {
        "summary": {
            "answers_are_editable":
            True,
            "collapsible":
            False,
            "custom_summary": [{
                "add_link":
                "/questionnaire/people/add-person/?return_to=section-summary",
                "add_link_text": "Add someone to this household",
                "empty_list_text": "There are no householders",
                "list": {
                    "editable":
                    True,
                    "list_items": [{
                        "item_title":
                        "Toni Morrison",
                        "primary_person":
                        False,
                        "edit_link":
                        "/questionnaire/people/PlwgoG/edit-person/?return_to=section-summary",
                        "remove_link":
                        "/questionnaire/people/PlwgoG/remove-person/?return_to=section-summary",
                    }],
                },
                "list_name": "people",
                "title": "Household members",
                "type": "List",
            }],
            "page_title":
            "List Collector Driving Question Summary",
            "summary_type":
            "SectionSummary",
            "title":
            "List Collector Driving Question Summary",
        }
    }

    assert context == expected
Exemplo n.º 18
0
def test_context_for_section_list_summary(people_answer_store):
    schema = load_schema_from_name("test_list_collector_section_summary")
    current_location = Location(section_id="section")

    summary_context = SectionSummaryContext(
        language=DEFAULT_LANGUAGE_CODE,
        schema=schema,
        answer_store=people_answer_store,
        list_store=ListStore([
            {
                "items": ["PlwgoG", "UHPLbX"],
                "name": "people"
            },
            {
                "items": ["gTrlio"],
                "name": "visitors"
            },
        ]),
        progress_store=ProgressStore(),
        metadata={"display_address": "70 Abingdon Road, Goathill"},
    )
    context = summary_context(current_location)

    expected = {
        "summary": {
            "answers_are_editable":
            True,
            "collapsible":
            False,
            "custom_summary": [
                {
                    "add_link":
                    "/questionnaire/people/add-person/?return_to=section-summary",
                    "add_link_text": "Add someone to this household",
                    "empty_list_text": "There are no householders",
                    "list": {
                        "editable":
                        True,
                        "list_items": [
                            {
                                "edit_link":
                                "/questionnaire/people/PlwgoG/edit-person/?return_to=section-summary",
                                "item_title":
                                "Toni Morrison",
                                "primary_person":
                                False,
                                "remove_link":
                                "/questionnaire/people/PlwgoG/remove-person/?return_to=section-summary",
                            },
                            {
                                "edit_link":
                                "/questionnaire/people/UHPLbX/edit-person/?return_to=section-summary",
                                "item_title":
                                "Barry Pheloung",
                                "primary_person":
                                False,
                                "remove_link":
                                "/questionnaire/people/UHPLbX/remove-person/?return_to=section-summary",
                            },
                        ],
                    },
                    "list_name": "people",
                    "title":
                    "Household members staying overnight on 13 October 2019 at 70 Abingdon Road, Goathill",
                    "type": "List",
                },
                {
                    "add_link":
                    "/questionnaire/visitors/add-visitor/?return_to=section-summary",
                    "add_link_text": "Add another visitor to this household",
                    "empty_list_text": "There are no visitors",
                    "list": {
                        "editable":
                        True,
                        "list_items": [{
                            "edit_link":
                            "/questionnaire/visitors/gTrlio/edit-visitor-person/?return_to=section-summary",
                            "item_title":
                            "",
                            "primary_person":
                            False,
                            "remove_link":
                            "/questionnaire/visitors/gTrlio/remove-visitor/?return_to=section-summary",
                        }],
                    },
                    "list_name": "visitors",
                    "title":
                    "Visitors staying overnight on 13 October 2019 at 70 Abingdon Road, Goathill",
                    "type": "List",
                },
            ],
            "page_title":
            "People who live here and overnight visitors",
            "summary_type":
            "SectionSummary",
            "title":
            "People who live here and overnight visitors",
        }
    }

    assert context == expected