Skip to content

Commit

Permalink
✅ [#4980] Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorvanwijk committed Jan 27, 2025
1 parent b49d07a commit fb8e6dc
Show file tree
Hide file tree
Showing 25 changed files with 530 additions and 460 deletions.
96 changes: 42 additions & 54 deletions src/openforms/authentication/tests/test_static_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,12 @@
from jsonschema.validators import Draft202012Validator

from openforms.authentication.constants import AuthAttribute
from openforms.authentication.static_variables.static_variables import (
Auth,
AuthBSN,
AuthContext,
AuthContextActingSubjectIdentifier,
AuthContextActingSubjectIdentifierType,
AuthContextBranchNumber,
AuthContextLegalSubjectIdentifier,
AuthContextLegalSubjectIdentifierType,
AuthContextLOA,
AuthContextRepresenteeIdentifier,
AuthContextRepresenteeType,
AuthContextSource,
AuthKvK,
AuthPseudo,
AuthType,
LanguageCode,
SubmissionID,
)
from openforms.authentication.tests.factories import AuthInfoFactory
from openforms.submissions.tests.factories import SubmissionFactory
from openforms.variables.service import get_static_variables

from ..static_variables.static_variables import register_static_variable as registry


class TestStaticVariables(TestCase):
def test_auth_static_data(self):
Expand Down Expand Up @@ -157,11 +140,16 @@ def test_branch_number_variable(self):
self.assertEqual(static_data["auth_context_branch_number"], expected)


# TODO-4980: move to openforms.utils.json_schema.tests?
class StaticVariableValidJsonSchemaTests(TestCase):

validator = Draft202012Validator

def check_schema(self, properties):
@staticmethod
def _get_json_schema(key: str):
return registry[key].as_json_schema()

def assertValidSchema(self, properties):
schema = {
"$schema": self.validator.META_SCHEMA["$id"],
**properties,
Expand All @@ -170,69 +158,69 @@ def check_schema(self, properties):
self.validator.check_schema(schema)

def test_submission_id(self):
schema = SubmissionID.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("submission_id")
self.assertValidSchema(schema)

def test_language_code(self):
schema = LanguageCode.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("language_code")
self.assertValidSchema(schema)

def test_auth(self):
schema = Auth.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth")
self.assertValidSchema(schema)

def test_auth_type(self):
schema = AuthType.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth_type")
self.assertValidSchema(schema)

def test_auth_bsn(self):
schema = AuthBSN.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth_bsn")
self.assertValidSchema(schema)

def test_auth_kvk(self):
schema = AuthKvK.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth_kvk")
self.assertValidSchema(schema)

def test_auth_pseudo(self):
schema = AuthPseudo.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth_pseudo")
self.assertValidSchema(schema)

def test_auth_context(self):
schema = AuthContext.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth_context")
self.assertValidSchema(schema)

def test_auth_context_source(self):
schema = AuthContextSource.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth_context_source")
self.assertValidSchema(schema)

def test_auth_context_loa(self):
schema = AuthContextLOA.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth_context_loa")
self.assertValidSchema(schema)

def test_auth_context_representee_type(self):
schema = AuthContextRepresenteeType.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth_context_representee_identifier_type")
self.assertValidSchema(schema)

def test_auth_context_representee_identifier(self):
schema = AuthContextRepresenteeIdentifier.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth_context_representee_identifier")
self.assertValidSchema(schema)

def test_auth_context_legal_subject_identifier_type(self):
schema = AuthContextLegalSubjectIdentifierType.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth_context_legal_subject_identifier_type")
self.assertValidSchema(schema)

def test_auth_context_legal_subject_identifier(self):
schema = AuthContextLegalSubjectIdentifier.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth_context_legal_subject_identifier")
self.assertValidSchema(schema)

def test_auth_context_branch_number(self):
schema = AuthContextBranchNumber.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth_context_branch_number")
self.assertValidSchema(schema)

def test_auth_context_acting_subject_identifier_type(self):
schema = AuthContextActingSubjectIdentifierType.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth_context_acting_subject_identifier_type")
self.assertValidSchema(schema)

def test_auth_context_acting_subject_identifier(self):
schema = AuthContextActingSubjectIdentifier.as_json_schema()
self.check_schema(schema)
schema = self._get_json_schema("auth_context_acting_subject_identifier")
self.assertValidSchema(schema)
6 changes: 3 additions & 3 deletions src/openforms/formio/tests/test_component_json_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
class ComponentValidJsonSchemaTests(TestCase):
validator = Draft202012Validator

def check_schema(self, properties):
def assertValidSchema(self, properties):
schema = {
"$schema": self.validator.META_SCHEMA["$id"],
**properties,
Expand All @@ -61,14 +61,14 @@ def _test_component(self, component_class, component, multiple=False):
with self.subTest(f"single {component['label']}"):
schema = component_class.as_json_schema(component)

self.check_schema(schema)
self.assertValidSchema(schema)

if multiple:
with self.subTest(f"multiple {component['label']}"):
component["multiple"] = True
schema = component_class.as_json_schema(component)

self.check_schema(schema)
self.assertValidSchema(schema)

def test_checkbox(self):
component_class = Checkbox
Expand Down
203 changes: 0 additions & 203 deletions src/openforms/forms/tests/test_form_to_json_schema.py

This file was deleted.

Loading

0 comments on commit fb8e6dc

Please sign in to comment.