From 8ac2081d3b73865a767d222f24ba94543cb02fd9 Mon Sep 17 00:00:00 2001 From: "vysakh.menon" Date: Mon, 29 Jan 2024 14:52:59 -0800 Subject: [PATCH] removed corpNumber --- .../example_data/schema_data.py | 4 +-- .../schemas/amalgamation_application.json | 29 +++++++------------ tests/unit/test_amalgamation_application.py | 20 +++++++++++++ 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/registry_schemas/example_data/schema_data.py b/src/registry_schemas/example_data/schema_data.py index 8322273..90a1487 100644 --- a/src/registry_schemas/example_data/schema_data.py +++ b/src/registry_schemas/example_data/schema_data.py @@ -107,9 +107,9 @@ }, { 'role': 'amalgamating', + 'identifier': '123456', 'legalName': 'Foreign Co.', - 'foreignJurisdiction': FOREIGN_JURISDICTION, - 'corpNumber': '123456' + 'foreignJurisdiction': FOREIGN_JURISDICTION } ], 'nameRequest': { diff --git a/src/registry_schemas/schemas/amalgamation_application.json b/src/registry_schemas/schemas/amalgamation_application.json index 9093641..c3fa258 100644 --- a/src/registry_schemas/schemas/amalgamation_application.json +++ b/src/registry_schemas/schemas/amalgamation_application.json @@ -31,21 +31,9 @@ "amalgamatingBusinesses": { "type": "array", "items": { - "oneOf": [ - { - "required": [ - "role", - "identifier" - ] - }, - { - "required": [ - "role", - "foreignJurisdiction", - "legalName", - "corpNumber" - ] - } + "required": [ + "role", + "identifier" ], "properties": { "role": { @@ -64,10 +52,15 @@ }, "legalName": { "type": "string" - }, - "corpNumber": { - "type": "string" } + }, + "dependencies": { + "foreignJurisdiction": [ + "legalName" + ], + "legalName": [ + "foreignJurisdiction" + ] } } }, diff --git a/tests/unit/test_amalgamation_application.py b/tests/unit/test_amalgamation_application.py index 1578b69..b9e9ac1 100644 --- a/tests/unit/test_amalgamation_application.py +++ b/tests/unit/test_amalgamation_application.py @@ -67,6 +67,26 @@ def test_amalgamation_schema_no_amalgamating_businesses(): assert not is_valid +@pytest.mark.parametrize('element', [ + ('legalName'), + ('foreignJurisdiction'), +]) +def test_amalgamation_schema_not_valid_foreign(element): + """Assert not valid if one of the field is not present.""" + amalgamation = copy.deepcopy(AMALGAMATION_APPLICATION) + aml_json = {'amalgamationApplication': amalgamation} + del aml_json['amalgamationApplication']['amalgamatingBusinesses'][1][element] + + is_valid, errors = validate(aml_json, 'amalgamation_application') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert not is_valid + + def test_amalgamation_schema_no_name_request(): """Assert not valid if nameRequest node is not present.""" amalgamation = copy.deepcopy(AMALGAMATION_APPLICATION)