Skip to content

Commit

Permalink
[#2170] Fixed test depending on mocked old behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart van der Schoor authored and alextreme committed Apr 2, 2024
1 parent 26453fc commit 380fa83
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 44 deletions.
12 changes: 3 additions & 9 deletions src/open_inwoner/accounts/tests/test_contact_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
from django.urls import reverse
from django.utils.translation import gettext_lazy as _

from cms import api
from django_webtest import WebTest

from open_inwoner.accounts.models import User
from open_inwoner.utils.tests.helpers import create_image_bytes

from ...cms.inbox.cms_apps import InboxApphook
from ...cms.tests import cms_tools
from ..choices import ContactTypeChoices
from .factories import DigidUserFactory, UserFactory

Expand Down Expand Up @@ -98,14 +99,7 @@ def test_messages_enabled_disabled(self):
self.assertNotContains(response, _("Stuur bericht"))

# case 2: unpublished message page
page = api.create_page(
"Mijn Berichten",
"cms/fullwidth.html",
"nl",
slug="berichten",
)
page.application_namespace = "inbox"
page.save()
page = cms_tools.create_apphook_page(InboxApphook, publish=False)

response = self.app.get(self.list_url, user=self.user)

Expand Down
41 changes: 7 additions & 34 deletions src/open_inwoner/accounts/tests/test_profile_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from django.utils.translation import gettext as _

import requests_mock
from cms import api
from django_webtest import WebTest
from pyquery import PyQuery as PQ
from webtest import Upload
Expand All @@ -26,6 +25,9 @@
from open_inwoner.utils.test import ClearCachesMixin
from open_inwoner.utils.tests.helpers import AssertTimelineLogMixin, create_image_bytes

from ...cms.cases.cms_apps import CasesApphook
from ...cms.collaborate.cms_apps import CollaborateApphook
from ...cms.inbox.cms_apps import InboxApphook
from ...cms.profile.cms_apps import ProfileApphook
from ...cms.tests import cms_tools
from ...haalcentraal.api_models import BRPData
Expand Down Expand Up @@ -261,14 +263,7 @@ def test_messages_enabled_disabled(self):
self.assertNotContains(response, _("Stuur een bericht"))

# case 2: unpublished message page
page = api.create_page(
"Mijn Berichten",
"cms/fullwidth.html",
"nl",
slug="berichten",
)
page.application_namespace = "inbox"
page.save()
page = cms_tools.create_apphook_page(InboxApphook, publish=False)

response = self.app.get(self.url, user=self.user)

Expand Down Expand Up @@ -971,14 +966,7 @@ def test_inbox_notifications_display(self):
self.assertNotIn("messages_notifications", form.fields)

# inbox page created but not published
page = api.create_page(
"Mijn Berichten",
"cms/fullwidth.html",
"nl",
slug="berichten",
)
page.application_namespace = "inbox"
page.save()
page = cms_tools.create_apphook_page(InboxApphook, publish=False)

response = self.app.get(self.url, user=self.user)
form = response.forms["change-notifications"]
Expand All @@ -1002,15 +990,7 @@ def test_cases_notifications_display(self):
self.assertNotIn("cases_notifications", form.fields)

# cases page created but not published
page = api.create_page(
"Mijn Aanvragen",
"cms/fullwidth.html",
"nl",
slug="aanvragen",
)
page.application_namespace = "cases"
page.save()

page = cms_tools.create_apphook_page(CasesApphook, publish=False)
response = self.app.get(self.url, user=self.user)
form = response.forms["change-notifications"]

Expand All @@ -1031,14 +1011,7 @@ def test_collaborate_notifications_display(self):
self.assertNotIn("plans_notifications", form.fields)

# collaborate page created but not published
page = api.create_page(
"Samenwerken",
"cms/fullwidth.html",
"nl",
slug="samenwerken",
)
page.application_namespace = "collaborate"
page.save()
page = cms_tools.create_apphook_page(CollaborateApphook, publish=False)

response = self.app.get(self.url, user=self.user)
form = response.forms["change-notifications"]
Expand Down
3 changes: 2 additions & 1 deletion src/open_inwoner/cms/tests/cms_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def create_apphook_page(
extension_args: dict = None,
config_args: dict = None,
parent_page=None,
publish=True,
):
p = api.create_page(
(title or hook_class.name),
Expand All @@ -129,7 +130,7 @@ def create_apphook_page(
# config_args["namespace"] = hook_class.app_name
# p.app_config = hook_class.app_config.objects.create(**config_args)

if not p.publish("nl"):
if publish and not p.publish("nl"):
raise Exception("failed to publish page")

return p

0 comments on commit 380fa83

Please sign in to comment.