def test_response_is_no_summaries_are_not_updated(
    erm_user, make_review, make_policy, make_summary_draft, django_app
):
    first_policy = make_policy(
        name="first", summary="first summary", summary_html=convert("first summary")
    )
    second_policy = make_policy(
        name="second", summary="second summary", summary_html=convert("second summary")
    )
    review = make_review(policies=[first_policy, second_policy])

    make_summary_draft(
        policy=first_policy, review=review, text="**new** ~first~ `summary`"
    )
    make_summary_draft(
        policy=second_policy, review=review, text="**new** ~second~ `summary`"
    )

    response = django_app.get(
        reverse("review:publish", kwargs={"slug": review.slug}), user=erm_user
    )

    form = response.forms[1]
    form["published"] = False
    form.submit()

    first_policy.refresh_from_db()
    second_policy.refresh_from_db()
    assert first_policy.summary == "first summary"
    assert first_policy.summary_html == convert("first summary")
    assert second_policy.summary == "second summary"
    assert second_policy.summary_html == convert("second summary")
 def clean(self):
     if not self.slug:
         self.slug = slugify(self.name)
     self.condition_html = convert(self.condition)
     self.summary_html = convert(self.summary)
     self.background_html = convert(self.background)
     self.archived_reason_html = convert(self.archived_reason)
Exemplo n.º 3
0
    def save(self, **kwargs):
        if not self.pk and not self.review_start:
            self.review_start = get_today()

        if not self.slug:
            self.slug = slugify(self.name)

        self.summary_html = convert(self.summary)
        self.background_html = convert(self.background)

        return super(Review, self).save(**kwargs)
def test_update_view__published(erm_user, django_app):
    """
    Test the preview page.
    """
    instance = baker.make(Policy, archived_reason="# heading", archived=False)

    update_page = django_app.get(
        reverse("policy:archive:update", args=(instance.slug,)), user=erm_user
    )
    update_form = update_page.forms[1]
    update_form["archived_reason"] = "# updated"

    preview_page = update_form.submit(name="preview")

    instance.refresh_from_db()
    assert instance.archived_reason == "# heading"

    preview_form = preview_page.forms[1]
    result = preview_form.submit(name="publish")

    assert result.status == "302 Found"
    assert result.url == reverse("policy:archive:complete", args=(instance.slug,))

    instance.refresh_from_db()
    assert instance.archived
    assert instance.archived_reason == "# updated"
    assert instance.archived_reason_html == convert("# updated")
def test_add_summary_view__updated(policy, erm_user, django_app):
    summary = django_app.get(reverse("policy:add:summary",
                                     args=(policy.slug, )),
                             user=erm_user)
    summary_form = summary.forms[1]

    summary_form["summary"] = "summary"
    summary_form["background"] = "background"

    result = summary_form.submit()

    assert result.status == "302 Found"
    assert result.url == reverse("policy:add:recommendation",
                                 args=(policy.slug, ))

    policy.refresh_from_db()

    assert policy.summary == "summary"
    assert policy.summary_html == convert("summary")
    assert policy.background == "background"
    assert policy.background_html == convert("background")
    assert not policy.is_active
def test_add_start_view__created(erm_user, django_app):
    start = django_app.get(reverse("policy:add:start"), user=erm_user)
    start_form = start.forms[1]

    start_form["name"] = "name"
    start_form["condition_type"] = Policy.CONDITION_TYPES.general
    start_form["condition"] = "condition"
    start_form["ages"] = [Policy.AGE_GROUPS.antenatal]
    start_form["keywords"] = "keywords"

    result = start_form.submit()

    assert result.status == "302 Found"
    assert result.url == reverse("policy:add:summary", args=("name", ))

    policy = Policy.objects.get(name="name")

    assert policy.condition_type == Policy.CONDITION_TYPES.general
    assert policy.condition == "condition"
    assert policy.condition_html == convert("condition")
    assert policy.ages == [Policy.AGE_GROUPS.antenatal]
    assert policy.keywords == "keywords"
    assert not policy.is_active
Exemplo n.º 7
0
def test_changes_are_published(erm_user, django_app):
    """
    Test the policy is updated when the changes are published.
    """
    instance = baker.make(Policy, condition="# heading", next_review=None)

    edit_page = django_app.get(instance.get_edit_url(), user=erm_user)
    edit_form = edit_page.forms[1]
    edit_form["next_review"] = today().year
    edit_form["condition_type"] = Policy.CONDITION_TYPES.general
    edit_form["ages"] = [Policy.AGE_GROUPS.antenatal]
    edit_form["condition"] = "# updated"

    preview_page = edit_form.submit(name="preview")

    instance.refresh_from_db()
    assert instance.condition == "# heading"

    preview_form = preview_page.forms[1]
    preview_form.submit(name="publish")

    instance.refresh_from_db()
    assert instance.condition == "# updated"
    assert instance.condition_html == convert("# updated")