Skip to content

Commit

Permalink
[#3283] Fixed/removed/updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vaszig committed Dec 6, 2024
1 parent c7de305 commit 3c36035
Show file tree
Hide file tree
Showing 22 changed files with 72 additions and 1,778 deletions.
7 changes: 3 additions & 4 deletions docs/developers/backend/core/submissions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Globally, the various actions and plugin categories are processed in order:

#. If applicable, an :ref:`appointment <developers_appointment_plugins>` is
created. If this fails, the submission is blocked and the user sees an error
message and can try again (note: this step is deprecated and not needed for the new appointment flow).
message and can try again.
#. Pre-registration step. Each :ref:`registration plugin <developers_registration_plugins>` can perform
pre-registration task, like for example generating and setting a submission reference ID. If no registration backend
is configured, then an internal ID is generated and set on the submission.
Expand All @@ -39,9 +39,8 @@ Globally, the various actions and plugin categories are processed in order:
the previous actions, the confirmation email shows different contents.

The confirmation email can show submission details, appointment details
(including links to cancel or change the appointment), payment details
(including a link to pay if not done so already), cosign details and custom information as part
of the form.
(including links to cancel the appointment), payment details(including a link to pay if not done so already),
cosign details and custom information as part of the form.

Under the hood
--------------
Expand Down
Binary file not shown.
83 changes: 0 additions & 83 deletions docs/manual/forms/examples/appointment_creation.rst

This file was deleted.

12 changes: 0 additions & 12 deletions docs/manual/forms/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,3 @@ Voorbeelden
suwinet
form_with_geometry
camunda7

======================
Verouderde voorbeelden
======================

Deze voorbeelden beschrijven functionaliteit die uitgefaseerd wordt. We raden af om nog
nieuwe formulieren hiermee te bouwen.

.. toctree::
:maxdepth: 1

appointment_creation
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_times_list(self):

self.assertEqual(response.status_code, status.HTTP_200_OK)
times = response.json()
self.assertEqual(len(times), 3)
self.assertEqual(len(times), 4)

def test_required_customer_fields_list(self):
endpoint = reverse("api:appointments-customer-fields")
Expand Down
16 changes: 10 additions & 6 deletions src/openforms/appointments/contrib/jcc/tests/test_api_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def test_get_locations_multiple_products(self, m):
def test_get_locations_returns_400_when_no_product_id_is_given(self):
response = self.client.get(self.endpoint)

self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), [])
self.assertEqual(response.status_code, 400)
self.assertEqual(response.json()["invalidParams"][0]["code"], "required")

def test_get_locations_returns_403_when_no_active_sessions(self):
self._clear_session()
Expand Down Expand Up @@ -165,8 +165,10 @@ def test_get_dates_returns_400_when_missing_query_params(self):
for query_param in [{}, {"product_id": 79}, {"location_id": 1}]:
with self.subTest(query_param=query_param):
response = self.client.get(self.endpoint, query_param)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), [])
self.assertEqual(response.status_code, 400)
self.assertEqual(
response.json()["invalidParams"][0]["code"], "required"
)

def test_get_dates_returns_403_when_no_active_sessions(self):
self._clear_session()
Expand Down Expand Up @@ -242,8 +244,10 @@ def test_get_times_returns_400_when_missing_query_params(self):
]:
with self.subTest(query_param=query_param):
response = self.client.get(self.endpoint, query_param)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), [])
self.assertEqual(response.status_code, 400)
self.assertEqual(
response.json()["invalidParams"][0]["code"], "required"
)

def test_get_times_returns_403_when_no_active_sessions(self):
self._clear_session()
Expand Down
23 changes: 19 additions & 4 deletions src/openforms/appointments/contrib/jcc/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from openforms.utils.xml import fromstring
from soap.tests.factories import SoapServiceFactory

from ....base import AppointmentDetails, Customer, CustomerDetails, Location, Product
from ....base import AppointmentDetails, CustomerDetails, Location, Product
from ....core import book
from ....exceptions import (
AppointmentCreateFailed,
Expand Down Expand Up @@ -251,7 +251,12 @@ def test_get_required_customer_fields(self, m):
def test_create_appointment(self, m):
product = Product(identifier="1", code="PASAAN", name="Paspoort aanvraag")
location = Location(identifier="1", name="Maykin Media")
client = Customer(last_name="Doe", birthdate=date(1980, 1, 1))
client = CustomerDetails(
details={
CustomerFields.last_name: "Doe",
CustomerFields.birthday: "1980-01-01",
}
)

m.post(
"http://example.com/soap11",
Expand Down Expand Up @@ -665,7 +670,12 @@ def test_get_times_unexpected_exception(self, m):
def test_create_appointment_failure(self, m):
product = Product(identifier="1", code="PASAAN", name="Paspoort aanvraag")
location = Location(identifier="1", name="Maykin Media")
client = Customer(last_name="Doe", birthdate=date(1980, 1, 1))
client = CustomerDetails(
details={
CustomerFields.last_name: "Doe",
CustomerFields.birthday: "1980-01-01",
}
)
start_at = datetime(2021, 8, 23, 6, 0, 0).replace(tzinfo=timezone.utc)
m.post(
"http://example.com/soap11",
Expand All @@ -681,7 +691,12 @@ def test_create_appointment_failure(self, m):
def test_create_appointment_unexpected_exception(self, m):
product = Product(identifier="1", code="PASAAN", name="Paspoort aanvraag")
location = Location(identifier="1", name="Maykin Media")
client = Customer(last_name="Doe", birthdate=date(1980, 1, 1))
client = CustomerDetails(
details={
CustomerFields.last_name: "Doe",
CustomerFields.birthday: "1980-01-01",
}
)
start_at = datetime(2021, 8, 23, 6, 0, 0).replace(tzinfo=timezone.utc)
m.post(requests_mock.ANY, exc=IOError("tubes are closed"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def test_get_locations_returns_all_locations_for_a_product(self, m):
def test_get_locations_returns_400_when_no_product_id_is_given(self):
response = self.client.get(self.endpoint)

self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), [])
self.assertEqual(response.status_code, 400)
self.assertEqual(response.json()["invalidParams"][0]["code"], "required")

def test_get_locations_returns_403_when_no_active_sessions(self):
self._clear_session()
Expand Down Expand Up @@ -156,8 +156,10 @@ def test_get_dates_returns_400_when_missing_query_params(self):
for query_param in [{}, {"product_id": 79}, {"location_id": 1}]:
with self.subTest(query_param=query_param):
response = self.client.get(self.endpoint, query_param)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), [])
self.assertEqual(response.status_code, 400)
self.assertEqual(
response.json()["invalidParams"][0]["code"], "required"
)

def test_get_dates_returns_403_when_no_active_sessions(self):
self._clear_session()
Expand Down Expand Up @@ -232,8 +234,10 @@ def test_get_times_returns_400_when_missing_query_params(self):
]:
with self.subTest(query_param=query_param):
response = self.client.get(self.endpoint, query_param)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), [])
self.assertEqual(response.status_code, 400)
self.assertEqual(
response.json()["invalidParams"][0]["code"], "required"
)

def test_get_times_returns_403_when_no_active_sessions(self):
self._clear_session()
Expand Down
23 changes: 19 additions & 4 deletions src/openforms/appointments/contrib/qmatic/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)
from openforms.utils.tests.logging import disable_logging

from ....base import AppointmentDetails, Customer, Location, Product
from ....base import AppointmentDetails, CustomerDetails, Location, Product
from ....core import book
from ....exceptions import (
AppointmentCreateFailed,
Expand Down Expand Up @@ -247,7 +247,12 @@ def test_create_appointment(self, m):
location = Location(
identifier="f364d92b7fa07a48c4ecc862de30c47", name="Branch 1"
)
client = Customer(last_name="Doe", birthdate=date(1980, 1, 1))
client = CustomerDetails(
details={
CustomerFields.last_name: "Doe",
CustomerFields.birthday: "1980-01-01",
}
)
day = datetime(2016, 12, 6, 9, 0, 0)

m.get(
Expand Down Expand Up @@ -529,7 +534,12 @@ def test_get_times_unexpected_exception(self, m):
def test_create_appointment_failure(self, m):
product = Product(identifier="1", code="PASAAN", name="Paspoort aanvraag")
location = Location(identifier="1", name="Maykin Media")
client = Customer(last_name="Doe", birthdate=date(1980, 1, 1))
client = CustomerDetails(
details={
CustomerFields.last_name: "Doe",
CustomerFields.birthday: "1980-01-01",
}
)
start_at = timezone.make_aware(datetime(2021, 8, 23, 6, 0, 0))
m.get(
f"{self.api_root}v1/branches/1",
Expand Down Expand Up @@ -576,7 +586,12 @@ def test_create_appointment_failure(self, m):
def test_create_appointment_unexpected_exception(self, m):
product = Product(identifier="1", code="PASAAN", name="Paspoort aanvraag")
location = Location(identifier="1", name="Maykin Media")
client = Customer(last_name="Doe", birthdate=date(1980, 1, 1))
client = CustomerDetails(
details={
CustomerFields.last_name: "Doe",
CustomerFields.birthday: "1980-01-01",
}
)
start_at = datetime(2021, 8, 23, 6, 0, 0).replace(tzinfo=timezone.utc)
m.get(
f"{self.api_root}v1/branches/1",
Expand Down
31 changes: 2 additions & 29 deletions src/openforms/appointments/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class TestPlugin(DemoAppointment):
@disable_admin_mfa()
class AppointmentInfoAdminTests(WebTest):
@freeze_time("2021-11-26T17:00:00+01:00")
def test_cancel_and_change_links_only_for_superuser(self):
def test_cancel_link_only_for_superuser(self):
normal, staff = [
UserFactory.create(user_permissions=["view_appointmentinfo"]),
StaffUserFactory.create(user_permissions=["view_appointmentinfo"]),
Expand Down Expand Up @@ -84,34 +84,7 @@ def test_cancel_and_change_links_only_for_superuser(self):
self.assertFalse(object_actions_col)

@freeze_time("2021-11-26T17:00:00+01:00")
def test_cancel_and_change_links_legacy(self):
user = SuperUserFactory.create()
# appointment in the past
AppointmentInfoFactory.create(
registration_ok=True, start_time="2021-11-01T17:00:00+01:00"
)
# appointment in the future
AppointmentInfoFactory.create(
registration_ok=True, start_time="2021-11-30T17:00:00+01:00"
)

changelist = self.app.get(
reverse("admin:appointments_appointmentinfo_changelist"), user=user
)

self.assertEqual(changelist.status_code, 200)
object_actions_col = changelist.pyquery(".field-get_object_actions")

# future appointment
app1_links = object_actions_col.eq(0).find("a")
self.assertEqual(len(app1_links), 2)

# past appointment
app2_links = object_actions_col.eq(1).find("a")
self.assertEqual(len(app2_links), 0)

@freeze_time("2021-11-26T17:00:00+01:00")
def test_cancel_and_change_links(self):
def test_cancel_link(self):

user = SuperUserFactory.create()
# appointment in the past
Expand Down
5 changes: 2 additions & 3 deletions src/openforms/appointments/tests/test_api_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,5 @@ def test_list_products_with_existing_product_invalid_query_param(self):

response = self.client.get(self.endpoint, {"product_id": [""]})

# XXX in 3.0, this will become HTTP 400
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), [])
self.assertEqual(response.status_code, 400)
self.assertEqual(response.json()["invalidParams"][0]["code"], "blank")
17 changes: 0 additions & 17 deletions src/openforms/appointments/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,3 @@ def test_get_cancel_link(self):
)
cancel_url = f"https://example.com{cancel_path}"
self.assertEqual(cancel_url, result)

@override_settings(BASE_URL="https://example.com/")
def test_get_change_link(self):
submission = SubmissionFactory.create(completed=True)
AppointmentInfoFactory.create(submission=submission, registration_ok=True)

result = self.plugin.get_change_link(submission)

change_path = reverse(
"appointments:appointments-verify-change-appointment-link",
kwargs={
"token": submission_appointment_token_generator.make_token(submission),
"submission_uuid": submission.uuid,
},
)
change_url = f"https://example.com{change_path}"
self.assertEqual(change_url, result)
Loading

0 comments on commit 3c36035

Please sign in to comment.