Skip to content

Commit

Permalink
Alteration filing changes (#35)
Browse files Browse the repository at this point in the history
* Conversion filing changes

* Alteration schema changes

* no message

* no message

* More tests

* Putting back the conversions

* Updating description in tests

* Changing the version
  • Loading branch information
Lekshmi authored Jul 6, 2020
1 parent e6ee574 commit e543cba
Show file tree
Hide file tree
Showing 10 changed files with 339 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/registry_schemas/example_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from .schema_data import (
ADDRESS,
ALL_FILINGS,
ALTERATION,
ALTERATION_FILING_TEMPLATE,
ANNUAL_REPORT,
BUSINESS,
CHANGE_OF_ADDRESS,
Expand Down Expand Up @@ -66,6 +68,8 @@
'SPECIAL_RESOLUTION',
'STUB_FILING',
'VOLUNTARY_DISSOLUTION',
'ALTERATION',
'ALTERATION_FILING_TEMPLATE',
'CONVERSION',
'CONVERSION_FILING_TEMPLATE'
]
59 changes: 59 additions & 0 deletions src/registry_schemas/example_data/schema_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,44 @@
}


ALTERATION = {
'provisionsRemoved': False,
'alterCorpType': {
'corpType': 'benefitCompany'
},
'alterCorpName': {
'legalName': 'new name',
'nrNumber': 'NR123567'
},
'alterNameTranslations': {
'modifiedTranslations': [{
'oldValue': 'A1 Ltd.',
'newValue': 'A2 Ltd'
}],
'ceasedTranslations': ['B1', 'B2']
},
'alterShareStructure': {
'resolutionDates': ['2020-05-23', '2020-06-01'],
'shareClasses': [{
'name': 'class1',
'priority': 1,
'maxNumberOfShares': 600,
'parValue': 1,
'currency': 'CAD',
'hasMaximumShares': True,
'hasParValue': True,
'hasRightsOrRestrictions': False,
'series': [{
'name': 'class1',
'priority': 1,
'maxNumberOfShares': 600,
'hasMaximumShares': True,
'hasRightsOrRestrictions': False
}]
}]
}
}

CONVERSION = {
'nameRequest': {
'legalType': 'BC'
Expand Down Expand Up @@ -1069,6 +1107,7 @@
}
}


FILING_TEMPLATE = {
'filing': {
'header': {
Expand Down Expand Up @@ -1109,6 +1148,25 @@
}
}

ALTERATION_FILING_TEMPLATE = {
'filing': {
'header': {
'name': 'alteration',
'date': '2020-06-25',
'certifiedBy': 'full name',
'email': '[email protected]',
'filingId': 1
},
'business': {
'foundingDate': '2018-01-01T00:00:00+00:00',
'identifier': 'U1234567',
'legalName': 'legal name - Test',
'legalType': 'ULC'
},
'alteration': ALTERATION
}
}

CONVERSION_FILING_TEMPLATE = {
'filing': {
'header': {
Expand Down Expand Up @@ -1153,6 +1211,7 @@
('appointReceiver', STUB_FILING),
('continuedOut', STUB_FILING),
('changeOfDirectors', CHANGE_OF_DIRECTORS_MAILING), # bcorp-specific version of filing
('alteration', ALTERATION),
('conversion', CONVERSION)
]

Expand Down
77 changes: 77 additions & 0 deletions src/registry_schemas/schemas/alteration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://bcrs.gov.bc.ca/.well_known/schemas/alteration",
"anyOf": [
{"required": ["alterCorpType"]},
{"required": ["alterCorpName"]},
{"required": ["alterNameTranslations"]},
{"required": ["alterShareStructure"]}
],
"type": "object",
"title": "Alteration Filing",
"properties": {
"provisionsRemoved": {
"type": "boolean",
"title": "Has Pre-existing company provisions?"
},
"alterCorpType": {
"type": "object",
"required": [
"corpType"
],
"properties": {
"corpType": {
"type": "string",
"title": "Corp type to which the business needs to be converted",
"enum": [
"benefitCompany"
]
}
}
},
"alterCorpName": {
"type": "object",
"required": [
"legalName",
"nrNumber"
],
"properties": {
"legalName": {
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/business#/definitions/legalName",
"title": "New Legal Name"
},
"nrNumber": {
"type": "string",
"maxLength": 10,
"title": "Name Request Number"
}
}
},
"alterNameTranslations": {
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/alteration_name_translations"
},
"alterShareStructure": {
"type": "object",
"title": "New Share Structure",
"required": [
"resolutionDates",
"shareClasses"
],
"properties": {
"resolutionDates": {
"type": "array",
"items": {
"type": "string",
"format": "date"
}
},
"shareClasses": {
"type": "array",
"items": {
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/share_class#/definitions/shareClass"
}
}
}
}
}
}
38 changes: 38 additions & 0 deletions src/registry_schemas/schemas/alteration_name_translations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://bcrs.gov.bc.ca/.well_known/schemas/alteration_name_translations",
"type": "object",
"title": "Change of name translations",
"anyOf": [
{"required": ["modifiedTranslations"]},
{"required": ["ceasedTranslations"]}
],
"properties": {
"modifiedTranslations": {
"type": "array",
"items": {
"type": "object",
"required": [
"oldValue",
"newValue"
],
"properties": {
"oldValue": {
"type": "string",
"title": "Old Translation"
},
"newValue": {
"type": "string",
"title": "New Translation"
}
}
}
},
"ceasedTranslations": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
2 changes: 1 addition & 1 deletion src/registry_schemas/schemas/conversion.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/agreementType"
}
}
}
}
4 changes: 4 additions & 0 deletions src/registry_schemas/schemas/filing.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"appointReceiver",
"continuedOut",
"correction",
"alteration",
"conversion"
]
},
Expand Down Expand Up @@ -231,6 +232,9 @@
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/conversion"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/alteration"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion src/registry_schemas/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
Development release segment: .devN
"""

__version__ = '2.5.14' # pylint: disable=invalid-name
__version__ = '2.5.15' # pylint: disable=invalid-name
2 changes: 2 additions & 0 deletions tests/unit/schema_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@
('todo.json'),
('voluntary_dissolution.json'),
('agreement_type.json'),
('alteration.json'),
('alteration_name_translations.json'),
('conversion.json')
]
127 changes: 127 additions & 0 deletions tests/unit/test_alteration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Copyright © 2019 Province of British Columbia
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Test Suite to ensure alteration schemas are valid."""

import copy

from registry_schemas import validate
from registry_schemas.example_data import ALTERATION


def test_alteration_schema():
"""Assert that the JSONSchema validator is working."""
is_valid, errors = validate(ALTERATION, 'alteration')

if errors:
for err in errors:
print(err.message)
print(errors)

assert is_valid


def test_validate_valid_alteration_with_any_required_element():
"""Assert valid if any of the required alterations is present."""
alteration_json = copy.deepcopy(ALTERATION)
del alteration_json['alterCorpName']
del alteration_json['alterCorpType']
del alteration_json['alterNameTranslations']

is_valid, errors = validate(alteration_json, 'alteration')

if errors:
for err in errors:
print(err.message)
print(errors)

assert is_valid


def test_validate_invalid_alteration_with_no_required_elements():
"""Assert not valid if none of the required alterations are present."""
alteration_json = copy.deepcopy(ALTERATION)
del alteration_json['alterCorpName']
del alteration_json['alterCorpType']
del alteration_json['alterNameTranslations']
del alteration_json['alterShareStructure']

is_valid, errors = validate(alteration_json, 'alteration')

if errors:
for err in errors:
print(err.message)
print(errors)

assert not is_valid


def test_validate_invalid_corp_name_alteration():
"""Assert not valid if corp name alteration does not contain required elements."""
alteration_json = copy.deepcopy(ALTERATION)
del alteration_json['alterCorpName']['legalName']

is_valid, errors = validate(alteration_json, 'alteration')

if errors:
for err in errors:
print(err.message)
print(errors)

assert not is_valid


def test_validate_invalid_corp_type_alteration():
"""Assert not valid if corp type is not valid."""
alteration_json = copy.deepcopy(ALTERATION)
alteration_json['alterCorpType']['corpType'] = 'ZZ'

is_valid, errors = validate(alteration_json, 'alteration')

if errors:
for err in errors:
print(err.message)
print(errors)

assert not is_valid


def test_validate_invalid_name_translation_alteration():
"""Assert not valid if name translation alteration does not contain mandatory elements."""
alteration_json = copy.deepcopy(ALTERATION)
del alteration_json['alterNameTranslations']['modifiedTranslations']
del alteration_json['alterNameTranslations']['ceasedTranslations']

is_valid, errors = validate(alteration_json, 'alteration')

if errors:
for err in errors:
print(err.message)
print(errors)

assert not is_valid


def test_validate_invalid_share_structure_alteration():
"""Assert not valid if share structure alteration does not contain required elements."""
alteration_json = copy.deepcopy(ALTERATION)
del alteration_json['alterShareStructure']['shareClasses']

is_valid, errors = validate(alteration_json, 'alteration')

if errors:
for err in errors:
print(err.message)
print(errors)

assert not is_valid
Loading

0 comments on commit e543cba

Please sign in to comment.